git-ecosystem/git-credential-manager · error · ArgumentOutOfRangeException
Argument must be strictly greater than
Error message
Argument must be strictly greater than {lower}. What it means
This ArgumentOutOfRangeException is thrown by EnsureArgument.InRange when lowerInclusive is false and the argument is less than or equal to the lower bound. With an exclusive lower bound the value must satisfy arg > lower strictly. The message interpolates the actual bound.
Solutions
- Ensure the value is strictly greater than lower; add +1 or clamp to lower + 1 if appropriate
- If the bound should be inclusive, pass lowerInclusive: true (the default) or use PositiveOrZero-style checks
- Document the exclusive-bound convention where the API is defined
- Check recent changes to the call site that switched inclusivity flags
Example fix
// before EnsureArgument.InRange(page, nameof(page), 1, 100, lowerInclusive: false); // page == 1 // after EnsureArgument.InRange(page, nameof(page), 1, 100); // inclusive: page >= 1 is valid
Defensive patterns
Strategy: validation
Validate before calling
// exclusive lower bound: value must be > lower if (value <= lower) value = lower + 1; EnsureArgument.InRange(value, nameof(value), lower, upper, lowerInclusive: false);
Type guard
static bool IsStrictlyAbove(int v, int lower) => v > lower;
Try / catch
try { EnsureArgument.InRange(page, nameof(page), 1, 100, lowerInclusive: false); }
catch (ArgumentOutOfRangeException ex)
{
throw new InvalidOperationException($"{ex.ParamName} must be > 1 (exclusive lower bound)", ex);
} Prevention
- Read the signature carefully: lowerInclusive defaults to true; pass false only intentionally
- Clarify inclusive vs exclusive conventions in API docs and tests
- Add boundary-value unit tests (lower, lower+1, upper-1, upper)
- Prefer the inclusive defaults unless the domain demands exclusivity
When it happens
Trigger: Calling EnsureArgument.InRange(arg, name, lower, upper, lowerInclusive: false) with arg <= lower, e.g., passing exactly the exclusive minimum, or forgetting that this overload treats the bound as exclusive.
Common situations: Confusion between inclusive and exclusive bound conventions when tightening validation; passing boundary values (arg == lower) that previously passed under the default inclusive behavior; off-by-one after a signature change.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Argument must be greater than or equal to
- Argument must be less than or equal to
- Argument must be strictly less than
- Argument must be positive or zero (non-negative).
- Argument must be positive.
AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11).
Data as JSON: /api/errors/edc116a2337beb45.
Report an issue: GitHub.
Appendix: source
Thrown at src/Core/EnsureArgument.cs:86
public static void Negative(int arg, string name)
{
if (arg >= 0)
{
throw new ArgumentOutOfRangeException(name, "Argument must be negative.");
}
}
public static void InRange(int arg, string name, int lower, int upper, bool lowerInclusive = true, bool upperInclusive = true)
{
if (lowerInclusive && arg < lower)
{
throw new ArgumentOutOfRangeException(name, $"Argument must be greater than or equal to {lower}.");
}
if (!lowerInclusive && arg <= lower)
{
throw new ArgumentOutOfRangeException(name, $"Argument must be strictly greater than {lower}.");
}
if (upperInclusive && arg > upper)
{
throw new ArgumentOutOfRangeException(name, $"Argument must be less than or equal to {upper}.");
}
if (!upperInclusive && arg >= upper)
{
throw new ArgumentOutOfRangeException(name, $"Argument must be strictly less than {upper}.");
}
}
}
}
View on GitHub (pinned to e8ce762cd0)