abpframework/abp · error · ArgumentException

{parameterName} is less than zero

Error message

{parameterName} is less than zero

What it means

Thrown by Check.Positive(Int16 value, string) when value < 0. Indicates a negative value was passed to a guard that requires strictly positive (>= 1) Int16 input. ArgumentException carrying the parameter name.

Source

Thrown at framework/src/Volo.Abp.Core/Volo/Abp/Check.cs:178

        if (value != null && value.Length > maxLength)
        {
            throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
        }

        return value;
    }

    public static Int16 Positive(
        Int16 value,
        [InvokerParameterName][NotNull] string parameterName)
    {
        if (value == 0)
        {
            throw new ArgumentException($"{parameterName} is equal to zero");
        }
        else if (value < 0)
        {
            throw new ArgumentException($"{parameterName} is less than zero");
        }
        return value;
    }

    public static Int32 Positive(
        Int32 value,
        [InvokerParameterName][NotNull] string parameterName)
    {
        if (value == 0)
        {
            throw new ArgumentException($"{parameterName} is equal to zero");
        }
        else if (value < 0)
        {
            throw new ArgumentException($"{parameterName} is less than zero");
        }
        return value;
    }

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Clamp the value to at least 1 before calling Check.Positive (Math.Max((short)1, value)).
  2. Fix the upstream computation producing the negative value.
  3. If negatives are allowed, switch to Check.Range(value, name, -32768) or remove the guard.
  4. Add input validation ([Range]) so negative inputs are rejected at the boundary.

Example fix

// before
Check.Positive((short)(end - start), nameof(length)); // start > end -> throws

// after
var length = (short)Math.Max(1, end - start);
Check.Positive(length, nameof(length));
Defensive patterns

Strategy: validation

Validate before calling

// Clamp negative Int16 to a positive floor before guarding
short safe = (short)Math.Max(1, value);
Check.Positive(safe, nameof(value));

Type guard

static bool IsPositiveShort(short v) => v > 0;

Prevention

When it happens

Trigger: Calling Check.Positive((short)x, nameof(x)) with x being a negative Int16. Surfaces when quantities, indices, or amounts must never be negative.

Common situations: A subtraction or delta that went negative; user-supplied negative number not clamped by the UI; parsing '-1' from config; an offset computed as end - start where start > end.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/624bc078f7f77e7e. Report an issue: GitHub.