gchq/CyberChef · error · OperationError

Switch Add-Equals can only be set to blank, . or x

Error message

Switch Add-Equals can only be set to blank, . or x

What it means

Thrown when the Add-Equals switch (args[37]) fails the same ^$|^[.x]$ regex as the Q-switches. It validates the single addition-row Equals control, which must be blank, '.', or 'x'.

Source

Thrown at src/core/operations/Colossus.mjs:404

            X2: lm[0], S1: lm[1], P5: lm[2]
        };

        const KRackOpt = args[6];
        const setProgram = args[7];

        if (KRackOpt === "Select Program" && setProgram !== "") {
            args = this.selectProgram(setProgram, args);
        }

        const re = new RegExp("^$|^[.x]$");
        for (let qr=0;qr<3;qr++) {
            for (let a=0;a<5;a++) {
                if (!re.test(args[((qr*7)+(a+9))]))
                    throw new OperationError("Switch R"+(qr+1)+"-Q"+(a+1)+" can only be set to blank, . or x");
            }
        }

        if (!re.test(args[37])) throw new OperationError("Switch Add-Equals can only be set to blank, . or x");
        if (!re.test(args[40])) throw new OperationError("Switch Total Motor can only be set to blank, . or x");

        // Q1,Q2,Q3,Q4,Q5,negate,counter1
        const qbusswitches = {
            condition: [
                {Qswitches: [args[9], args[10], args[11], args[12], args[13]], Negate: args[14], Counter: args[15]},
                {Qswitches: [args[16], args[17], args[18], args[19], args[20]], Negate: args[21], Counter: args[22]},
                {Qswitches: [args[23], args[24], args[25], args[26], args[27]], Negate: args[28], Counter: args[29]}
            ],
            condNegateAll: args[30],
            addition: [
                {Qswitches: [args[32], args[33], args[34], args[35], args[36]], Equals: args[37], C1: args[38]}
            ],
            addNegateAll: args[39],
            totalMotor: args[40]
        };

        const settotal = parseInt(args[42], 10);

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Set args[37] (Switch Add-Equals) to '', '.', or 'x'.
  2. Normalize uppercase/numeric encodings to lowercase x or blank.
  3. When using 'Select Program', verify the preset populates args[37] correctly.

Example fix

// before
// args[37] = "1"  // throws
// after
// args[37] = "x"
Defensive patterns

Strategy: validation

Validate before calling

const SWITCH_RE = /^$|^[.x]$/;
if (!SWITCH_RE.test(args[37])) { /* fix Add-Equals before run */ }

Type guard

function isValidSwitch(v) { return /^$|^[.x]$/.test(v); }

Try / catch

null

Prevention

When it happens

Trigger: Colossus.run tests args[37] (the Equals slot of the addition Q-bus condition) against the regex; any value other than '', '.', 'x' throws. This is the same constraint as [249] applied to a different switch index.

Common situations: Same as [249]: uppercase 'X', stray '1'/'0', null from an incomplete preset, or paste artifacts in the Equals field.

Related errors


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