{"record":{"id":"51d60e7128ccfb57","repo":"gchq/CyberChef","slug":"4-custom-lugs-must-be-26-long-and-can-only-includ","errorCode":null,"errorMessage":"Χ4 custom lugs must be 26 long and can only include . or x","messagePattern":"Χ4 custom lugs must be 26 long and can only include \\. or x","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/Lorenz.mjs","lineNumber":292,"sourceCode":"        if (x3<1 || x3>29) throw new OperationError(\"Χ3 start must be between 1 and 29\");\n        if (x4<1 || x4>26) throw new OperationError(\"Χ4 start must be between 1 and 26\");\n        if (x5<1 || x5>23) throw new OperationError(\"Χ5 start must be between 1 and 23\");\n\n        // Initialise chosen wheel pattern\n        let chosenSetting = \"\";\n        if (pattern === \"Custom\") {\n            const re = new RegExp(\"^[.xX]*$\");\n            if (lugs1.length !== 43 || !re.test(lugs1)) throw new OperationError(\"Ψ1 custom lugs must be 43 long and can only include . or x \");\n            if (lugs2.length !== 47 || !re.test(lugs2)) throw new OperationError(\"Ψ2 custom lugs must be 47 long and can only include . or x\");\n            if (lugs3.length !== 51 || !re.test(lugs3)) throw new OperationError(\"Ψ3 custom lugs must be 51 long and can only include . or x\");\n            if (lugs4.length !== 53 || !re.test(lugs4)) throw new OperationError(\"Ψ4 custom lugs must be 53 long and can only include . or x\");\n            if (lugs5.length !== 59 || !re.test(lugs5)) throw new OperationError(\"Ψ5 custom lugs must be 59 long and can only include . or x\");\n            if (lugm37.length !== 37 || !re.test(lugm37)) throw new OperationError(\"M37 custom lugs must be 37 long and can only include . or x\");\n            if (lugm61.length !== 61 || !re.test(lugm61)) throw new OperationError(\"M61 custom lugs must be 61 long and can only include . or x\");\n            if (lugx1.length !== 41 || !re.test(lugx1)) throw new OperationError(\"Χ1 custom lugs must be 41 long and can only include . or x\");\n            if (lugx2.length !== 31 || !re.test(lugx2)) throw new OperationError(\"Χ2 custom lugs must be 31 long and can only include . or x\");\n            if (lugx3.length !== 29 || !re.test(lugx3)) throw new OperationError(\"Χ3 custom lugs must be 29 long and can only include . or x\");\n            if (lugx4.length !== 26 || !re.test(lugx4)) throw new OperationError(\"Χ4 custom lugs must be 26 long and can only include . or x\");\n            if (lugx5.length !== 23 || !re.test(lugx5)) throw new OperationError(\"Χ5 custom lugs must be 23 long and can only include . or x\");\n            chosenSetting = INIT_PATTERNS[\"No Pattern\"];\n            chosenSetting.S[1] = this.readLugs(lugs1);\n            chosenSetting.S[2] = this.readLugs(lugs2);\n            chosenSetting.S[3] = this.readLugs(lugs3);\n            chosenSetting.S[4] = this.readLugs(lugs4);\n            chosenSetting.S[5] = this.readLugs(lugs5);\n            chosenSetting.M[1] = this.readLugs(lugm61);\n            chosenSetting.M[2] = this.readLugs(lugm37);\n            chosenSetting.X[1] = this.readLugs(lugx1);\n            chosenSetting.X[2] = this.readLugs(lugx2);\n            chosenSetting.X[3] = this.readLugs(lugx3);\n            chosenSetting.X[4] = this.readLugs(lugx4);\n            chosenSetting.X[5] = this.readLugs(lugx5);\n        } else {\n            chosenSetting = INIT_PATTERNS[pattern];\n        }\n        const chiSettings = chosenSetting.X; // Pin settings for Chi links (X)","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/Lorenz.mjs#L274-L310","documentation":"Thrown by the Lorenz SZ operation when 'Wheel Pattern' is 'Custom' and the Χ4 (chi-4) lug string (arg[29], 'Χ4 lugs (26)') is invalid. The Χ4 wheel has 26 cam positions; the value must be exactly 26 characters matching /^[.xX]*$/. Enforced at Lorenz.mjs:292, after the Χ1–Χ3 checks pass.","triggerScenarios":"pattern='Custom' with lugx4 of length != 26 or containing characters outside {'.', 'x', 'X'}.","commonSituations":"Reusing a 29-char Χ3 pattern for Χ4; alphabet-size tables that quote chi-4 at a different length; trailing whitespace or newline from a copy/paste; using uppercase 'O' instead of 'x'.","solutions":["Set the Χ4 lug string to exactly 26 characters using only '.', 'x', or 'X' (26 is the chi-4 wheel cam count).","Use a preset wheel pattern (KH/ZMUG/BREAM/No Pattern) instead of 'Custom' to skip the check.","Validate length and alphabet before invoking the operation.","Confirm the field is Χ4 and the source pattern is for the chi-4 wheel."],"exampleFix":"// before\nlugx4 = \"xx..x..xxxx..xx.xxx....x\";   // 25 chars\n\n// after — exactly 26 chars\nlugx4 = \"xx..x..xxxx..xx.xxx....x..\";","handlingStrategy":"validation","validationCode":"const CHI4_LEN = 26;\nconst lugRe = /^[.xX]*$/;\nfunction validChi4(lugx4) {\n  return typeof lugx4 === 'string' && lugx4.length === CHI4_LEN && lugRe.test(lugx4);\n}\nif (!validChi4(args[29])) throw new Error('Χ4 lugs must be 26 chars of . x X');","typeGuard":"function isChi4Lugs(v): v is string {\n  return typeof v === 'string' && v.length === 26 && /^[.xX]*$/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Verify chi-4 length is exactly 26 before running.","Trim trailing newlines/spaces from pasted patterns.","Use the dropdown preset when custom chi-4 is unnecessary."],"tags":["lorenz","cipher","validation","input-length","wheel-pattern"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}