gchq/CyberChef · error · OperationError

Error: Radix argument must be between 2 and 36

Error message

Error: Radix argument must be between 2 and 36

What it means

Thrown by From Base when the Radix argument is outside the inclusive range 2-36. BigNumber and JavaScript's parseInt only support bases in this range, so the operation rejects anything else up front. This is an argument-validation error, not a data error.

Source

Thrown at src/core/operations/FromBase.mjs:45

        this.outputType = "BigNumber";
        this.args = [
            {
                "name": "Radix",
                "type": "number",
                "value": 36
            }
        ];
    }

    /**
     * @param {string} input
     * @param {Object[]} args
     * @returns {BigNumber}
     */
    run(input, args) {
        const radix = args[0];
        if (radix < 2 || radix > 36) {
            throw new OperationError("Error: Radix argument must be between 2 and 36");
        }

        const number = input.replace(/\s/g, "").split(".");
        let result = new BigNumber(number[0], radix);

        if (number.length === 1) return result;

        // Fractional part
        const radixBN = new BigNumber(radix);
        for (let i = 0; i < number[1].length; i++) {
            const digit = new BigNumber(number[1][i], radix);
            result = result.plus(digit.div(radixBN.pow(i + 1)));
        }

        return result;
    }

}

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Set the Radix arg to a value between 2 and 36 inclusive.
  2. For base 45/58/64/85, use the dedicated From Base45 / From Base58 / From Base64 / From Base85 operations instead.
  3. Validate the radix value in your calling code before invoking.

Example fix

// before: radix 64 (use the Base64 op instead)
fromBase.run(input, [64]) // throws
// after: valid radix
fromBase.run(input, [36])
Defensive patterns

Strategy: validation

Validate before calling

const radix = args[0];
if (radix < 2 || radix > 36) {
  // clamp or reject before calling fromBase.run()
}

Type guard

function isValidRadix(r) {
  return Number.isInteger(r) && r >= 2 && r <= 36;
}

Try / catch

try {
  fromBase.run(input, args);
} catch (e) {
  if (e.type === 'OperationError' && /Radix argument must be between/.test(e.message)) {
    // fix the radix arg; use a dedicated op for base 45/58/64/85
  } else throw e;
}

Prevention

When it happens

Trigger: Manually setting the Radix arg to a value < 2 or > 36; passing 0, 1, 64, or a negative number; a recipe/config that supplies an out-of-range radix.

Common situations: Confusing From Base (radix 2-36) with base-45/58/64/85 operations which have their own dedicated ops; user-typed recipe config with a typo; programmatic invocation with an unvalidated radix.

Related errors


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