gchq/CyberChef · error · OperationError
${this.name} must be an integer.
Error message
${this.name} must be an integer. What it means
Thrown by Ingredient.validate() when type is 'number', the value is a valid number, but the ingredient has integer:true set and Number.isInteger(checkVal) is false (line 133). The number is finite but fractional.
Source
Thrown at src/core/Ingredient.mjs:133
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) {
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);View on GitHub (pinned to 4290ea7539)
Solutions
- Pass an integer value (Math.round / Math.floor the computed value before assigning).
- If fractional values are acceptable, set integer:false in the ingredient config.
- Validate Number.isInteger(value) before assigning ingValues.
Example fix
// before op.ingValues = [3.5]; // integer:true ingredient // after op.ingValues = [Math.round(3.5)]; // 4
Defensive patterns
Strategy: validation
Validate before calling
if (ingredient.integer && typeof val === 'number' && !Number.isInteger(val)) {
throw new Error(`${name} must be an integer`);
} Type guard
function isInteger(v): v is number { return typeof v === 'number' && Number.isInteger(v); } Try / catch
try { op.ingValues = [val]; } catch (e) { if (/must be an integer/.test(e.message)) { val = Math.round(val); } } Prevention
- Round/floor computed values before assigning to integer ingredients.
- Set integer:false in config if fractional values are valid.
- Validate Number.isInteger on the client side.
When it happens
Trigger: An integer-only ingredient (block size, bit length, iteration count, radix) receives a decimal value such as 3.5 from the recipe.
Common situations: User types a decimal into an integer field; a computed arg (division, log) yields a fractional result fed back as an ingredient; recipe imported from a tool that emits floats.
Related errors
- ${this.name} must be a number.
- ${this.name} must be greater than or equal to ${this.min}.
- ${this.name} must be less than or equal to ${this.max}.
- ${this.name} cannot be empty.
- ${this.name} length cannot exceed ${this.maxLength}.
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/16e53c91c62c3f5b.
Report an issue: GitHub.