{"record":{"id":"2be8a3a549f69cda","repo":"gchq/CyberChef","slug":"lorenz-model-type-not-recognised","errorCode":null,"errorMessage":"Lorenz model type not recognised","messagePattern":"Lorenz model type not recognised","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/Lorenz.mjs","lineNumber":438,"sourceCode":"                     // p5 back 2\n                    if (lim===p5[2]) {\n                        lim=0;\n                    } else {\n                        lim=1;\n                    }\n                }\n                // If basic motor = 0 and limitation = 1, Total motor = 0 [no move], otherwise, total motor = 1 [move]\n                if (basicmotor===0 && lim===1) {\n                    totalmotor = 0;\n                } else {\n                    totalmotor = 1;\n                }\n\n            } else if (model===\"SZ40\") {\n                // SZ40 - just move based on the M37 motor wheel\n                totalmotor = basicmotor;\n            } else {\n                throw new OperationError(\"Lorenz model type not recognised\");\n            }\n\n            // Move the Psi wheels when current totalmotor active\n            if (totalmotor === 1) {\n                if (--s1 < 1) s1 = 43;\n                if (--s2 < 1) s2 = 47;\n                if (--s3 < 1) s3 = 51;\n                if (--s4 < 1) s4 = 53;\n                if (--s5 < 1) s5 = 59;\n            }\n\n            m61lug = muSettings[1][m61-1];\n            m37lug = muSettings[2][m37-1];\n\n            let rtnstr = self.REVERSE_ITA2_TABLE[resultStr];\n            if (format===\"5/8/9\") {\n                if (rtnstr===\"+\") rtnstr=\"5\"; // + or 5 used to represent figure shift\n                if (rtnstr===\"-\") rtnstr=\"8\"; // - or 8 used to represent letter shift","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/Lorenz.mjs#L420-L456","documentation":"Thrown by the Lorenz SZ operation when the 'Model' argument (args[0]) is not one of the recognised model identifiers. The run() method branches on 'SZ42a'/'SZ42b' and 'SZ40'; any other value falls through to the final else at Lorenz.mjs:438. In the UI the Model field is an option list of ['SZ40','SZ42a','SZ42b'], so this error is essentially only reachable through the Node API / recipe JSON when a model string is supplied that is missing, misspelled, or from a newer/older schema.","triggerScenarios":"Invoking the Lorenz operation with args[0] set to anything other than exactly 'SZ40', 'SZ42a', or 'SZ42b' — e.g. 'sz40', 'SZ42', 'SZ42B', 'Lorenz SZ42a', undefined, or an empty string. The error is raised at Lorenz.mjs:438 after the motor-stepping logic, during per-character processing.","commonSituations":"Programmatically building a recipe with a lowercase or differently-cased model string; a recipe JSON exported from a different CyberChef version whose model enum changed; passing a whole-word label ('SZ42a (with limitation)') instead of the bare token.","solutions":["Set args[0] ('Model') to exactly one of 'SZ40', 'SZ42a', or 'SZ42b' (case-sensitive).","When loading a recipe JSON, normalise the model string to upper-case and map known aliases (e.g. 'sz42b' -> 'SZ42b') before running.","In the UI, pick the model from the dropdown rather than typing it.","Verify the recipe was exported from a compatible CyberChef version."],"exampleFix":"// before\nchef.bake(Lorenz, input, [\"sz42a\", /* ... */]);\n\n// after\nchef.bake(Lorenz, input, [\"SZ42a\", /* ... */]);","handlingStrategy":"type-guard","validationCode":"const ALLOWED_MODELS = ['SZ40', 'SZ42a', 'SZ42b'];\nfunction normaliseModel(m) {\n  const up = String(m).toUpperCase();\n  return ALLOWED_MODELS.find(x => x.toUpperCase() === up);\n}\nconst model = normaliseModel(args[0]);\nif (!model) throw new Error(`Unsupported Lorenz model: ${args[0]}`);","typeGuard":"const LORENZ_MODELS = ['SZ40', 'SZ42a', 'SZ42b'] as const;\ntype LorenzModel = typeof LORENZ_MODELS[number];\nfunction isLorenzModel(v: unknown): v is LorenzModel {\n  return typeof v === 'string' && (LORENZ_MODELS as readonly string[]).includes(v);\n}","tryCatchPattern":null,"preventionTips":["Always source the model string from the defined option list, never hand-type it.","Normalise imported recipe model strings (case, aliases) before running.","Validate the model against the allow-list at recipe-load time."],"tags":["lorenz","cipher","validation","enum","config"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}