gchq/CyberChef · warning · OperationError
Invalid key length, required to be integer.
Error message
Invalid key length, required to be integer.
What it means
Third validation in Generate De Bruijn Sequence: requires key length `n` to be an integer. Catches fractional n (e.g. 3.5) since the recursion and array sizing assume a whole count of symbol positions. NaN/Infinity are also rejected.
Source
Thrown at src/core/operations/GenerateDeBruijnSequence.mjs:58
/**
* @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.");
}
const a = new Array(k * n).fill(0);
const sequence = [];
(function db(t = 1, p = 1) {
if (t > n) {
if (n % p !== 0) return;
for (let j = 1; j <= p; j++) {
sequence.push(a[j]);View on GitHub (pinned to 4290ea7539)
Solutions
- Round n to a whole number.
- Enter only integers in the Key length field.
- Wrap computed n with Math.round/Math.floor.
Example fix
// before args = [2, 3.5]; // after args = [2, 4];
Defensive patterns
Strategy: validation
Validate before calling
if (!Number.isInteger(n)) throw new Error("Key length n must be an integer"); Type guard
function isInt(n){return Number.isInteger(n);} Prevention
- Round n before passing.
- Enter whole numbers only in the key length field.
When it happens
Trigger: Entering a decimal key length like 3.5; a computed float passed programmatically without rounding.
Common situations: Number field accepting decimals; scripting with an unrounded computed value.
Related errors
- Invalid alphabet size, required to be integer.
- Invalid alphabet size, required to be between 2 and 9 (inclu
- Invalid key length, required to be at least 2.
- 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/6a386992e9ce1d38.
Report an issue: GitHub.