gchq/CyberChef · error · OperationError

Set Total must be between 0000 and 9999

Error message

Set Total must be between 0000 and 9999

What it means

Thrown when the parsed Set Total value (parseInt(args[42],10)) is outside 0–9999 inclusive. The Colossus counters are 4-decade decimal counters, so Set Total must be a four-digit-or-less non-negative number.

Source

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

        // 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);
        if (settotal < 0 || settotal > 9999)
            throw new OperationError("Set Total must be between 0000 and 9999");

        // null|fast|slow for each of S1-5,M1-2,X1-5
        const control = {
            fast: args[43],
            slow: args[44]
        };

        // Start positions
        if (args[52]<1 || args[52]>43) throw new OperationError("Ψ1 start must be between 1 and 43");
        if (args[53]<1 || args[53]>47) throw new OperationError("Ψ2 start must be between 1 and 47");
        if (args[54]<1 || args[54]>51) throw new OperationError("Ψ3 start must be between 1 and 51");
        if (args[55]<1 || args[55]>53) throw new OperationError("Ψ4 start must be between 1 and 53");
        if (args[56]<1 || args[57]>59) throw new OperationError("Ψ5 start must be between 1 and 59");
        if (args[51]<1 || args[51]>37) throw new OperationError("Μ37 start must be between 1 and 37");
        if (args[50]<1 || args[50]>61) throw new OperationError("Μ61 start must be between 1 and 61");
        if (args[45]<1 || args[45]>41) throw new OperationError("Χ1 start must be between 1 and 41");
        if (args[46]<1 || args[46]>31) throw new OperationError("Χ2 start must be between 1 and 31");
        if (args[47]<1 || args[47]>29) throw new OperationError("Χ3 start must be between 1 and 29");

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Enter a Set Total in the range 0000–9999 as a decimal integer.
  2. Avoid negative values and values ≥10000.
  3. Guard against NaN: if args[42] is non-numeric, supply 0 explicitly rather than relying on this check (NaN bypasses it).

Example fix

// before
// args[42] = "12345"  // > 9999, throws
// after
// args[42] = "9999"
Defensive patterns

Strategy: validation

Validate before calling

const settotal = parseInt(args[42], 10);
if (!Number.isFinite(settotal) || settotal < 0 || settotal > 9999) { /* fix before run */ }

Type guard

function isValidSetTotal(v) { const n = parseInt(v, 10); return Number.isFinite(n) && n >= 0 && n <= 9999; }

Try / catch

null

Prevention

When it happens

Trigger: Colossus.run reads args[42], parseInt's it base 10, and throws if <0 or >9999. A non-numeric string parses to NaN, and NaN comparisons are false so NaN slips through (no throw) — but a numeric value above 9999 or below 0 throws. Leading '−' or large values are the real triggers.

Common situations: User enters a 5-digit total, a negative number, or copies a hex-looking value expecting it parsed as decimal. NaN from empty/garbage input does NOT throw here (latent gap) but surfaces later.

Related errors


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