abpframework/abp · error · ArgumentException
{parameterName} is equal to zero
Error message
{parameterName} is equal to zero What it means
Thrown by Check.Positive(Int16 value, string) when value == 0. 'Positive' in ABP strictly means greater than zero, so zero is rejected. It is an ArgumentException (not ArgumentOutOfRangeException) naming the parameter.
Source
Thrown at framework/src/Volo.Abp.Core/Volo/Abp/Check.cs:174
throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
}
}
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)
{View on GitHub (pinned to 7ed43b1931)
Solutions
- Pass a strictly positive Int16 (>= 1) for the argument.
- If zero is semantically valid, replace Check.Positive with a custom range/nullable guard or Check.Range(value, name, 0).
- Default the field to 1 (or another positive seed) at construction instead of leaving it 0.
- Validate input upstream (e.g. [Range(1, short.MaxValue)]) so the error surfaces as a validation message.
Example fix
// before Check.Positive((short)pageNumber, nameof(pageNumber)); // pageNumber == 0 -> throws // after var page = (short)Math.Max(1, pageNumber); Check.Positive(page, nameof(page));
Defensive patterns
Strategy: validation
Validate before calling
// Ensure strictly positive Int16 before guarding short safe = value > 0 ? value : (short)1; Check.Positive(safe, nameof(value));
Type guard
static bool IsPositiveShort(short v) => v > 0;
Prevention
- Remember ABP 'Positive' means > 0; zero is rejected. Use Check.Range(v, name, 0) if zero is valid.
- Default Int16 fields to 1 (not 0) when they must be positive.
- Add [Range(1, short.MaxValue)] on DTOs for positive 16-bit fields.
When it happens
Trigger: Calling Check.Positive((short)count, nameof(count)) when count is 0. Used to guard quantities, counts, sequence numbers, and other signed 16-bit fields that must be at least 1.
Common situations: A paging/skip-take where page is 0; a quantity or priority field left at its default of 0; parsing user input that yielded 0 for an Id; an enum/flag cast to Int16 landing on 0.
Related errors
- {parameterName} is less than zero
- {parameterName} is out of range min: {minimumValue} - max: {
- {parameterName} (type of {type.AssemblyQualifiedName}) shoul
- Given tenant doesn't exist: {0}
- Given tenant isn't available: {0}
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/8f62a77531e5a43e.
Report an issue: GitHub.