abpframework/abp · error · ArgumentException
{parameterName} can not be null, empty or white space!
Error message
{parameterName} can not be null, empty or white space! What it means
Check.NotNullOrWhiteSpace(string) rejects null, empty, or all-whitespace strings using IsNullOrWhiteSpace(), so whitespace-only values also fail (stricter than NotNullOrEmpty). After the whitespace check it applies optional maxLength/minLength bounds. Use this when the string must carry meaningful content, not just be present.
Source
Thrown at framework/src/Volo.Abp.Core/Volo/Abp/Check.cs:72
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,
[InvokerParameterName][NotNull] string parameterName,
int maxLength = int.MaxValue,
int minLength = 0)
{
if (value.IsNullOrWhiteSpace())
{
throw new ArgumentException($"{parameterName} can not be null, empty or white space!", 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 NotNullOrEmpty(
[System.Diagnostics.CodeAnalysis.NotNull] string? value,View on GitHub (pinned to 7ed43b1931)
Solutions
- Pass a non-empty, non-whitespace string.
- If blank is a valid 'unset' state, default-fall to a meaningful value at the caller before calling.
- Trim input upstream and validate before forwarding into the guarded API.
Example fix
// before Check.NotNullOrWhiteSpace(raw, nameof(raw)); // throws on blank // after Check.NotNullOrWhiteSpace(string.IsNullOrWhiteSpace(raw) ? "default" : raw, nameof(raw));
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(value))
value = fallback;
Check.NotNullOrWhiteSpace(value, nameof(value)); Type guard
bool IsMeaningful(string? s) => !string.IsNullOrWhiteSpace(s);
Prevention
- Trim and default-fall blank input at the caller before guarded APIs.
- Prefer Check.NotNullOrWhiteSpace over NotNullOrEmpty when blank must fail.
- Use [Required] on DTO properties so model binding rejects whitespace before your code runs.
When it happens
Trigger: Check.NotNullOrWhiteSpace(" ", nameof(x)), or an empty string, or null; an ABP API that requires a non-blank value receiving whitespace.
Common situations: Configuration keys that must have a value; display names; identifiers that cannot be whitespace; trimmed user input that ended up blank.
Related errors
- repositoryNameWithOrganization '{repositoryNameWithOrganizat
- Can not set {companyName} if {companyNamePlaceHolder} is nul
- {parameterName} can not be null!
- {parameterName} length must be equal to or lower than {maxLe
- {parameterName} length must be equal to or bigger than {minL
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/4b5bccee4e18c8de.
Report an issue: GitHub.