abpframework/abp · error · ArgumentException
{parameterName} can not be null!
Error message
{parameterName} can not be null! What it means
The string overload of Check.NotNull validates that a string is non-null and within optional maxLength/minLength bounds (defaults: maxLength=int.MaxValue, minLength=0). This overload deliberately throws ArgumentException (not ArgumentNullException) with a human-readable message; it differs from the generic Check.NotNull<T> which throws ArgumentNullException. It is ABP's standard pre-condition guard used pervasively across the framework.
Source
Thrown at framework/src/Volo.Abp.Core/Volo/Abp/Check.cs:47
{
if (value == null)
{
throw new ArgumentNullException(parameterName, message);
}
return value;
}
[ContractAnnotation("value:null => halt")]
public static string NotNull(
[System.Diagnostics.CodeAnalysis.NotNull] string? value,
[InvokerParameterName][NotNull] string parameterName,
int maxLength = int.MaxValue,
int minLength = 0)
{
if (value == null)
{
throw new ArgumentException($"{parameterName} can not be null!", parameterName);
}
if (value.Length > maxLength)
{
throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
}
if (minLength > 0 && value.Length < minLength)
{
throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
}
return value;
}
[ContractAnnotation("value:null => halt")]
public static string NotNullOrWhiteSpace(
[System.Diagnostics.CodeAnalysis.NotNull] string? value,View on GitHub (pinned to 7ed43b1931)
Solutions
- Pass a non-null string.
- If the value may legitimately be absent, resolve to a default (e.g. string.Empty) at the caller before invoking the guarded API.
- Trace the parameter name in the message back to the offending argument.
Example fix
// before Check.NotNull(maybeNull, nameof(maybeNull)); // after Check.NotNull(maybeNull ?? string.Empty, nameof(maybeNull));
Defensive patterns
Strategy: validation
Validate before calling
if (value is null) throw new ArgumentNullException(nameof(value)); // or resolve to a default before the guarded call: Check.NotNull(value ?? string.Empty, nameof(value));
Type guard
bool IsPresent(string? s) => s is not null;
Prevention
- Coalesce optional strings to a default at the caller before invoking guarded ABP APIs.
- Enable nullable reference types so the compiler warns on null propagation.
- Trace the parameter name in the message back to the offending argument.
When it happens
Trigger: Check.NotNull(someString, nameof(someString)) when someString is null; equivalently an ABP internal call guarding a string parameter receives null.
Common situations: Passing null where a required string (name, key, connection string) is expected; a config value resolved to null and forwarded into an ABP API.
Related errors
- repositoryNameWithOrganization '{repositoryNameWithOrganizat
- Can not set {companyName} if {companyNamePlaceHolder} is nul
- {parameterName} length must be equal to or lower than {maxLe
- {parameterName} length must be equal to or bigger than {minL
- {parameterName} can not be null, empty or white space!
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/3c8957b3341f8898.
Report an issue: GitHub.