gchq/CyberChef · error · OperationError
Size must be greater than 0
Error message
Size must be greater than 0
What it means
Thrown by the Shake operation when the 'Size' argument (output length) is negative. SHAKE is an extendable-output function whose output size is user-controlled, and a negative size is meaningless. Note the guard checks size < 0, so a size of 0 passes this check but the message says 'greater than 0', a minor mismatch between message and guard.
Source
Thrown at src/core/operations/Shake.mjs:53
"name": "Size",
"type": "number",
"value": 512
}
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const capacity = parseInt(args[0], 10),
size = args[1];
let algo;
if (size < 0)
throw new OperationError("Size must be greater than 0");
switch (capacity) {
case 128:
algo = JSSHA3.shake128;
break;
case 256:
algo = JSSHA3.shake256;
break;
default:
throw new OperationError("Invalid size");
}
return algo(input, size);
}
}
export default Shake;View on GitHub (pinned to 4290ea7539)
Solutions
- Set the Size argument to a positive integer (default is 512).
- If computing size dynamically, clamp it to a minimum of 1 before passing.
- Be aware that 0 currently passes the guard but produces empty output - use a positive value.
Example fix
// before run(input, ["256", -16]) // after run(input, ["256", 512])
Defensive patterns
Strategy: validation
Validate before calling
const capacity = parseInt(args[0], 10);
const size = args[1];
if (typeof size !== "number" || size < 0) {
throw new Error("Shake size must be a non-negative integer.");
}
// safe to invoke Shake (note: 0 currently passes but yields empty output) Type guard
function isValidShakeSize(size) {
return typeof size === "number" && Number.isFinite(size) && size > 0;
} Try / catch
try {
chef.shake(input, { capacity: "256", size: 512 });
} catch (e) {
// e.message indicates the size or capacity problem.
} Prevention
- Keep Size at the default 512 unless you need a specific output length.
- Clamp any computed size to a minimum of 1.
- Remember only capacities 128 and 256 are valid.
When it happens
Trigger: The 'Size' number argument is set to a negative value in the recipe. Can occur when a UI field is edited to a negative number or when a recipe is constructed programmatically with a negative size.
Common situations: Manual entry error in the Size field; recipe imported with a corrupted/typo'd size value; arithmetic that computes size from another field producing a negative result.
Related errors
- Invalid size
- Invalid size
- Invalid size
- Invalid block cipher mode: ${mode}
- Invalid ciphertext length: ${originalLength} bytes. Must be
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/6e8af4bee89865f8.
Report an issue: GitHub.