gchq/CyberChef · error · OperationError

${this.name} length cannot exceed ${this.maxLength}.

Error message

${this.name} length cannot exceed ${this.maxLength}.

What it means

Thrown by Ingredient.validate() maxLength check when checkVal is a string whose .length exceeds the ingredient's configured maxLength. maxLength is an optional numeric cap declared in the ingredient config; when set, it bounds string, Array, and Uint8Array values. Only the string branch is reported here (line 117).

Source

Thrown at src/core/Ingredient.mjs:117

        }

        if (isEmpty) {
            let isAllowedOptionEmpty = false;
            if (this.type === "option" && Array.isArray(this.defaultValue)) {
                isAllowedOptionEmpty = this.defaultValue.includes("");
            } else if (this.type === "argSelector" && Array.isArray(this.defaultValue)) {
                isAllowedOptionEmpty = this.defaultValue.some(opt => opt.name === "");
            }
            if (this.allowEmpty === false || ((this.type === "option" || this.type === "argSelector") && !isAllowedOptionEmpty)) {
                throw new OperationError(`${this.name} cannot be empty.`);
            }
            return true;
        }

        // 2. maxLength check
        if (typeof this.maxLength === "number" && checkVal !== null && checkVal !== undefined) {
            if (typeof checkVal === "string" && checkVal.length > this.maxLength) {
                throw new OperationError(`${this.name} length cannot exceed ${this.maxLength}.`);
            }
            if (Array.isArray(checkVal) && checkVal.length > this.maxLength) {
                throw new OperationError(`${this.name} length cannot exceed ${this.maxLength}.`);
            }
            if (checkVal instanceof Uint8Array && checkVal.length > this.maxLength) {
                throw new OperationError(`${this.name} length cannot exceed ${this.maxLength}.`);
            }
        }

        // 3. number checks
        if (this.type === "number") {
            if (checkVal === null || checkVal === undefined || isNaN(checkVal)) {
                throw new OperationError(`${this.name} must be a number.`);
            }
            if (this.integer && !Number.isInteger(checkVal)) {
                throw new OperationError(`${this.name} must be an integer.`);
            }
            if (typeof this.min === "number" && checkVal < this.min) {

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Truncate or shorten the input string to be within maxLength.
  2. If the cap is wrong for your use case, raise maxLength in the ingredient config (and re-verify the operation can handle larger input).
  3. Validate length client-side before assigning ingValues.

Example fix

// before
op.ingValues = ['abcdefghijklmnopqrstuvwxyz0123456789']; // 36 chars, maxLength 32

// after
op.ingValues = ['abcdefghijklmnopqrstuvwxyz012345']; // <= 32
Defensive patterns

Strategy: validation

Validate before calling

if (typeof val === 'string' && maxLength != null && val.length > maxLength) {
  throw new Error(`string length ${val.length} > maxLength ${maxLength}`);
}

Type guard

function fitsMaxLength(v, max): v is string { return typeof v === 'string' && (max == null || v.length <= max); }

Try / catch

try { op.ingValues = [val]; } catch (e) { if (/length cannot exceed/.test(e.message)) { /* truncate */ } }

Prevention

When it happens

Trigger: A string ingredient with maxLength:N receives a string longer than N characters; e.g. a key/delimiter ingredient capped at 32 chars gets a 64-char value from the recipe.

Common situations: User pastes a long key/salt/IV into a capped field; a recipe generated programmatically passes an oversized string; a delimiter or seed field overflow.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/8d565db5a39ba41a. Report an issue: GitHub.