gchq/CyberChef · error · OperationError
Ψ2 start must be between 1 and 47
Error message
Ψ2 start must be between 1 and 47
What it means
Thrown by the Lorenz operation when the Ψ2 wheel start position is out of range. The Ψ2 wheel has 47 cams, so the 1-indexed start must be in [1, 47]. Guard is on line 266 of src/core/operations/Lorenz.mjs.
Source
Thrown at src/core/operations/Lorenz.mjs:266
lugx5 = args[30];
let s1 = args[7],
s2 = args[8],
s3 = args[9],
s4 = args[10],
s5 = args[11],
m37 = args[12],
m61 = args[13],
x1 = args[14],
x2 = args[15],
x3 = args[16],
x4 = args[17],
x5 = args[18];
this.reverseTable();
if (s1<1 || s1>43) throw new OperationError("Ψ1 start must be between 1 and 43");
if (s2<1 || s2>47) throw new OperationError("Ψ2 start must be between 1 and 47");
if (s3<1 || s3>51) throw new OperationError("Ψ3 start must be between 1 and 51");
if (s4<1 || s4>53) throw new OperationError("Ψ4 start must be between 1 and 53");
if (s5<1 || s5>59) throw new OperationError("Ψ5 start must be between 1 and 59");
if (m37<1 || m37>37) throw new OperationError("Μ37 start must be between 1 and 37");
if (m61<1 || m61>61) throw new OperationError("Μ61 start must be between 1 and 61");
if (x1<1 || x1>41) throw new OperationError("Χ1 start must be between 1 and 41");
if (x2<1 || x2>31) throw new OperationError("Χ2 start must be between 1 and 31");
if (x3<1 || x3>29) throw new OperationError("Χ3 start must be between 1 and 29");
if (x4<1 || x4>26) throw new OperationError("Χ4 start must be between 1 and 26");
if (x5<1 || x5>23) throw new OperationError("Χ5 start must be between 1 and 23");
// Initialise chosen wheel pattern
let chosenSetting = "";
if (pattern === "Custom") {
const re = new RegExp("^[.xX]*$");
if (lugs1.length !== 43 || !re.test(lugs1)) throw new OperationError("Ψ1 custom lugs must be 43 long and can only include . or x ");
if (lugs2.length !== 47 || !re.test(lugs2)) throw new OperationError("Ψ2 custom lugs must be 47 long and can only include . or x");
if (lugs3.length !== 51 || !re.test(lugs3)) throw new OperationError("Ψ3 custom lugs must be 51 long and can only include . or x");View on GitHub (pinned to 4290ea7539)
Solutions
- Set the Ψ2 start argument to an integer in [1, 47].
- Clamp generated values with `((n - 1) % 47) + 1`.
- Reset the wheel-start fields to defaults (1) and re-enter carefully.
Example fix
// before: args[8] = 48 -> throws // after: args[8] = 1 -> ok
Defensive patterns
Strategy: validation
Validate before calling
// Ψ2 start (args[8]) must be in [1, 47]
function clampWheelStart(n, size) {
if (!Number.isFinite(n)) throw new Error(`start must be a number, got ${n}`);
return ((Math.floor(n) - 1) % size + size) % size + 1;
}
args[8] = clampWheelStart(args[8], 47); Type guard
const isPsi2Start = (v) => Number.isInteger(v) && v >= 1 && v <= 47;
Try / catch
try {
lorenz.run(input, args);
} catch (err) {
if (err instanceof OperationError && /Ψ2 start/.test(err.message)) {
args[8] = 1;
} else throw err;
} Prevention
- Remember each psi wheel has a distinct cam count; do not reuse one wheel's range for another.
- Default unset wheel positions to 1, not 0.
- Fold generated values into [1, 47] before running.
When it happens
Trigger: Calling Lorenz.run() with args[8] ('Ψ2 start (1-47)') less than 1 or greater than 47.
Common situations: Setting Ψ2 to 0 by mistake; confusing the 47-cam Ψ2 range with another wheel's; recipe imported with an out-of-range value.
Related errors
- Ψ1 start must be between 1 and 43
- Ψ3 start must be between 1 and 51
- Ψ4 start must be between 1 and 53
- Ψ5 start must be between 1 and 59
- Μ37 start must be between 1 and 37
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/80e4fa4e266a3459.
Report an issue: GitHub.