gchq/CyberChef · warning · OperationError
Invalid alphabet size, required to be between 2 and 9 (inclu
Error message
Invalid alphabet size, required to be between 2 and 9 (inclusive).
What it means
First validation in Generate De Bruijn Sequence: rejects alphabet size `k` outside 2..9 inclusive. The De Bruijn generator allocates an array of size k*n and branches over k symbols, so the bound keeps memory and runtime sane. Note the ordering quirk: this range check runs BEFORE the integer check, so a non-integer k that is also out of range (e.g. 1.5 or 10.5) hits this message rather than the integer one.
Source
Thrown at src/core/operations/GenerateDeBruijnSequence.mjs:50
},
{
name: "Key length (n)",
type: "number",
value: 3
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const [k, n] = args;
if (k < 2 || k > 9) {
throw new OperationError("Invalid alphabet size, required to be between 2 and 9 (inclusive).");
}
if (!Number.isInteger(k)) {
throw new OperationError("Invalid alphabet size, required to be integer.");
}
if (!Number.isInteger(n)) {
throw new OperationError("Invalid key length, required to be integer.");
}
if (n < 2) {
throw new OperationError("Invalid key length, required to be at least 2.");
}
if (Math.pow(k, n) > 50000) {
throw new OperationError("Too many permutations, please reduce k^n to under 50,000.");
}
View on GitHub (pinned to 4290ea7539)
Solutions
- Set Alphabet size (k) to an integer between 2 and 9 inclusive.
- If you need a larger alphabet, reduce n so k^n stays under 50,000, but k itself cannot exceed 9 in this op.
- Enter whole numbers only in the k field.
Example fix
// before args = [10, 3]; // after args = [9, 3];
Defensive patterns
Strategy: validation
Validate before calling
if (!Number.isInteger(k) || k < 2 || k > 9) throw new Error("Alphabet size k must be an integer in [2, 9]"); Type guard
/** @param {number} k */
function isValidAlphabetSize(k){return Number.isInteger(k) && k >= 2 && k <= 9;} Prevention
- Treat k as a small integer alphabet cardinality (2..9).
- Validate both integer-ness and range before calling the op.
- Remember the op caps k at 9 regardless of n budget.
When it happens
Trigger: Setting Alphabet size (k) to 1, 0, a negative, 10+, or any non-integer value that falls outside 2..9 (e.g. k=10 or k=1.5 both fail here).
Common situations: Mistaking k for key length; entering a large alphabet assuming the op supports arbitrary bases; passing a float because the number field accepted decimals.
Related errors
- Invalid key length, required to be at least 2.
- Invalid alphabet size, required to be integer.
- Invalid key length, required to be integer.
- Too many permutations, please reduce k^n to under 50,000.
- Invalid block cipher mode: ${mode}
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/f993f26f7781a18a.
Report an issue: GitHub.