gchq/CyberChef · error · OperationError

Lorenz model type not recognised

Error message

Lorenz model type not recognised

What it means

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.

Source

Thrown at src/core/operations/Lorenz.mjs:438

                     // p5 back 2
                    if (lim===p5[2]) {
                        lim=0;
                    } else {
                        lim=1;
                    }
                }
                // If basic motor = 0 and limitation = 1, Total motor = 0 [no move], otherwise, total motor = 1 [move]
                if (basicmotor===0 && lim===1) {
                    totalmotor = 0;
                } else {
                    totalmotor = 1;
                }

            } else if (model==="SZ40") {
                // SZ40 - just move based on the M37 motor wheel
                totalmotor = basicmotor;
            } else {
                throw new OperationError("Lorenz model type not recognised");
            }

            // Move the Psi wheels when current totalmotor active
            if (totalmotor === 1) {
                if (--s1 < 1) s1 = 43;
                if (--s2 < 1) s2 = 47;
                if (--s3 < 1) s3 = 51;
                if (--s4 < 1) s4 = 53;
                if (--s5 < 1) s5 = 59;
            }

            m61lug = muSettings[1][m61-1];
            m37lug = muSettings[2][m37-1];

            let rtnstr = self.REVERSE_ITA2_TABLE[resultStr];
            if (format==="5/8/9") {
                if (rtnstr==="+") rtnstr="5"; // + or 5 used to represent figure shift
                if (rtnstr==="-") rtnstr="8"; // - or 8 used to represent letter shift

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Set args[0] ('Model') to exactly one of 'SZ40', 'SZ42a', or 'SZ42b' (case-sensitive).
  2. When loading a recipe JSON, normalise the model string to upper-case and map known aliases (e.g. 'sz42b' -> 'SZ42b') before running.
  3. In the UI, pick the model from the dropdown rather than typing it.
  4. Verify the recipe was exported from a compatible CyberChef version.

Example fix

// before
chef.bake(Lorenz, input, ["sz42a", /* ... */]);

// after
chef.bake(Lorenz, input, ["SZ42a", /* ... */]);
Defensive patterns

Strategy: type-guard

Validate before calling

const ALLOWED_MODELS = ['SZ40', 'SZ42a', 'SZ42b'];
function normaliseModel(m) {
  const up = String(m).toUpperCase();
  return ALLOWED_MODELS.find(x => x.toUpperCase() === up);
}
const model = normaliseModel(args[0]);
if (!model) throw new Error(`Unsupported Lorenz model: ${args[0]}`);

Type guard

const LORENZ_MODELS = ['SZ40', 'SZ42a', 'SZ42b'] as const;
type LorenzModel = typeof LORENZ_MODELS[number];
function isLorenzModel(v: unknown): v is LorenzModel {
  return typeof v === 'string' && (LORENZ_MODELS as readonly string[]).includes(v);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/2be8a3a549f69cda. Report an issue: GitHub.