gchq/CyberChef · error · OperationError

${this.name} must be less than or equal to ${this.max}.

Error message

${this.name} must be less than or equal to ${this.max}.

What it means

Thrown by Ingredient.validate() when type is 'number', the value is a valid number, but it exceeds the ingredient's configured max (line 139). max is an optional numeric ceiling declared in the ingredient config.

Source

Thrown at src/core/Ingredient.mjs:139

            }
            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) {
                throw new OperationError(`${this.name} must be greater than or equal to ${this.min}.`);
            }
            if (typeof this.max === "number" && checkVal > this.max) {
                throw new OperationError(`${this.name} must be less than or equal to ${this.max}.`);
            }
        }

        // 4. option checks
        if (this.type === "option") {
            if (Array.isArray(this.defaultValue)) {
                const permittedOptions = this.defaultValue.filter(opt => {
                    if (typeof opt !== "string") return false;
                    return !opt.match(/^\[\/?[a-z0-9 -()^]+\]$/i);
                });
                const valStr = (checkVal !== null && checkVal !== undefined) ? String(checkVal).toLowerCase() : "";
                const matchedOption = permittedOptions.find(opt => opt.toLowerCase() === valStr);
                if (!matchedOption) {
                    throw new OperationError(`${this.name} must be one of the following: ${permittedOptions.join(", ")}.`);
                }
            }
        }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Lower the value to at most max.
  2. If the ceiling is wrong, raise max in the ingredient config and re-verify.
  3. Clamp with Math.min(max, value) before assigning.

Example fix

// before - max is 1023
op.ingValues = [2000];

// after
op.ingValues = [1023];
Defensive patterns

Strategy: validation

Validate before calling

if (typeof max === 'number' && val > max) throw new Error(`${name} > max ${max}`);

Type guard

function atOrBelowMax(v, max): v is number { return typeof v === 'number' && (max == null || v <= max); }

Try / catch

try { op.ingValues = [val]; } catch (e) { if (/less than or equal to/.test(e.message)) { val = max; } }

Prevention

When it happens

Trigger: A numeric ingredient with max:N receives a value strictly greater than N; e.g. an offset ingredient with max:1023 gets 2000.

Common situations: User enters a too-large value for length/rounds/offset; programmatic recipe generation overshoots; an operation tightened its max in a newer version.

Related errors


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