gchq/CyberChef · error · OperationError
Length must be greater than 0
Error message
Length must be greater than 0
What it means
Thrown by GenerateLoremIpsum's checkLimits() helper when the length argument is less than 1. This is a lower-bound validation that applies to all length types before the per-type maximum check. Fractional or zero/negative lengths are rejected.
Source
Thrown at src/core/operations/GenerateLoremIpsum.mjs:82
default:
throw new OperationError("Invalid length type");
}
}
}
export default GenerateLoremIpsum;
/**
* check combined validity of lengthType and length arguments
* @param {string} lengthType
* @param {number} length
* @throws {OperationError}
*/
function checkLimits(lengthType, length) {
if (length < 1) {
throw new OperationError("Length must be greater than 0");
}
switch (lengthType) {
case "Paragraphs":
case "Sentences":
case "Words":
if (length > maxLoremWords) {
throw new OperationError("Length must be less than " + maxLoremWords);
}
break;
case "Bytes":
if (length > maxLoremCharacters) {
throw new OperationError("Length must be less than " + maxLoremCharacters);
}
break;
default:
throw new OperationError("Invalid length type");
}View on GitHub (pinned to 4290ea7539)
Solutions
- Set length to a positive integer (>= 1).
- Validate that the length ingredient is a number and not NaN before invoking.
Example fix
// before args = [0, "Words"]; // after args = [10, "Words"];
Defensive patterns
Strategy: validation
Validate before calling
if (!Number.isInteger(length) || length < 1) {
// reject before invoking; length must be a positive integer
} Type guard
function isPositiveLength(n) {
return Number.isInteger(n) && n >= 1;
} Prevention
- Default the length field to a sensible positive integer.
- Reject zero, negative, or NaN lengths at the input boundary.
When it happens
Trigger: Passing length = 0, a negative number, or a value that coerces to < 1 (e.g. NaN from a non-numeric ingredient).
Common situations: Default/empty length field, or a UI control that allows zero.
Related errors
- Invalid length type
- Length must be less than ${maxLoremWords}
- Length must be less than ${maxLoremCharacters}
- Bit length must be at least 2
- Error: Radix argument must be between 2 and 36
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/c73ffdd92bd7ebe0.
Report an issue: GitHub.