abpframework/abp · error · ArgumentException

{parameterName} length must be equal to or lower than {maxLe

Error message

{parameterName} length must be equal to or lower than {maxLength}!

What it means

The maxLength branch of Check.NotNull(string) fires when value.Length exceeds the optional maxLength (default int.MaxValue, so this only triggers when a caller passes an explicit limit). It enforces schema/column-style length bounds at the API boundary, before data reaches a DB or validator downstream.

Source

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

        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,
        [InvokerParameterName][NotNull] string parameterName,
        int maxLength = int.MaxValue,
        int minLength = 0)
    {
        if (value.IsNullOrWhiteSpace())

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Truncate or validate the input length before calling.
  2. Raise maxLength if the current bound is too tight for the real data.
  3. Confirm the data shape (e.g. column width) matches the enforced limit.

Example fix

// before
Check.NotNull(longValue, nameof(longValue), maxLength: 50); // throws if >50

// after
Check.NotNull(longValue, nameof(longValue), maxLength: 200);
Defensive patterns

Strategy: validation

Validate before calling

if (value is not null && value.Length > maxLength)
    value = value.Substring(0, maxLength);
Check.NotNull(value, nameof(value), maxLength: maxLength);

Type guard

bool WithinMax(string s, int max) => s.Length <= max;

Prevention

When it happens

Trigger: Check.NotNull(value, nameof(value), maxLength: 50) with a value longer than 50 characters; an ABP internal guard with a column-width limit receiving oversized input.

Common situations: User input longer than the backing DB column; an undersized maxLength on a field whose real data is larger; forgetting to truncate free-text input.

Related errors


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