gchq/CyberChef · error · OperationError
Χ2 start must be between 1 and 31
Error message
Χ2 start must be between 1 and 31
What it means
The Colossus operation simulates the WWII Lorenz SZ40/42 cipher broken by the Colossus computer. Each wheel has a fixed number of cam positions; the chi-2 (Χ2) wheel has exactly 31. The start position is a 1-based index into that wheel, so it must satisfy 1 <= value <= 31. The guard `if (args[46]<1 || args[46]>31)` rejects anything outside that inclusive range before constructing the ColossusComputer.
Source
Thrown at src/core/operations/Colossus.mjs:441
if (settotal < 0 || settotal > 9999)
throw new OperationError("Set Total must be between 0000 and 9999");
// null|fast|slow for each of S1-5,M1-2,X1-5
const control = {
fast: args[43],
slow: args[44]
};
// Start positions
if (args[52]<1 || args[52]>43) throw new OperationError("Ψ1 start must be between 1 and 43");
if (args[53]<1 || args[53]>47) throw new OperationError("Ψ2 start must be between 1 and 47");
if (args[54]<1 || args[54]>51) throw new OperationError("Ψ3 start must be between 1 and 51");
if (args[55]<1 || args[55]>53) throw new OperationError("Ψ4 start must be between 1 and 53");
if (args[56]<1 || args[57]>59) throw new OperationError("Ψ5 start must be between 1 and 59");
if (args[51]<1 || args[51]>37) throw new OperationError("Μ37 start must be between 1 and 37");
if (args[50]<1 || args[50]>61) throw new OperationError("Μ61 start must be between 1 and 61");
if (args[45]<1 || args[45]>41) throw new OperationError("Χ1 start must be between 1 and 41");
if (args[46]<1 || args[46]>31) throw new OperationError("Χ2 start must be between 1 and 31");
if (args[47]<1 || args[47]>29) throw new OperationError("Χ3 start must be between 1 and 29");
if (args[48]<1 || args[48]>26) throw new OperationError("Χ4 start must be between 1 and 26");
if (args[49]<1 || args[49]>23) throw new OperationError("Χ5 start must be between 1 and 23");
const starts = {
X1: args[45], X2: args[46], X3: args[47], X4: args[48], X5: args[49],
M61: args[50], M37: args[51],
S1: args[52], S2: args[53], S3: args[54], S4: args[55], S5: args[56]
};
const colossus = new ColossusComputer(input, pattern, qbusin, qbusswitches, control, starts, settotal, limit);
const result = colossus.run();
return result;
}
/**
* Select ProgramView on GitHub (pinned to 4290ea7539)
Solutions
- Set the Χ2 start argument to an integer in the inclusive range [1, 31].
- If you loaded a known key setting, re-check it against the Lorenz SZ chi-2 wheel length of 31.
- When scripting the Node API, clamp or validate all twelve start positions against their wheel sizes (Χ: 41,31,29,26,23; Μ: 61,37; Ψ: 43,47,51,53,59) before baking.
Example fix
// before const args = setupArgs(); args[46] = 32; // throws: Χ2 start must be between 1 and 31 // after args[46] = 31; // valid: chi-2 wheel has 31 positions
Defensive patterns
Strategy: validation
Validate before calling
const CHI2_START_MAX = 31;
function validChi2Start(v) {
return Number.isInteger(v) && v >= 1 && v <= CHI2_START_MAX;
}
if (!validChi2Start(starts.X2)) {
throw new Error(`Χ2 start ${starts.X2} out of range [1, ${CHI2_START_MAX}]`);
} Type guard
function isChi2Start(v) {
return Number.isInteger(v) && v >= 1 && v <= 31;
} Prevention
- Validate every wheel start against its fixed size before baking: Χ(41,31,29,26,23), Μ(61,37), Ψ(43,47,51,53,59).
- Remember start positions are 1-based, not 0-based.
- When transcribing a key setting, label each value with its wheel name to avoid column misalignment.
When it happens
Trigger: Setting the 'Χ2 start' recipe argument (args[46]) to 0, a negative number, or any integer greater than 31 (e.g. 32, 40). Also triggered by passing a non-integer/string that coerces out of range, or by transposing wheel sizes when filling in all twelve start positions.
Common situations: Off-by-one from assuming 0-based indexing; copying a start vector from a source that used different wheel numbering; confusing Χ2's 31 positions with another wheel's size. Note: the adjacent line 437 has a latent bug (`args[57]>59` instead of `args[56]>59` for Ψ5) — unrelated to this error but worth flagging when editing this block.
Related errors
- Χ3 start must be between 1 and 29
- Χ4 start must be between 1 and 26
- Error opening image. (${err})
- Unsupported QR code format.
- Unknown padding type: ${padding}
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/51550f40e7fac741.
Report an issue: GitHub.