gchq/CyberChef · error · OperationError

Error: Input must be a number

Error message

Error: Input must be a number

What it means

To Base rejects input that is falsy (`!input`). Because the operation expects a BigNumber and renders it in a target radix, a missing/null/undefined input (no valid number produced upstream) cannot be converted. Note the truthiness check means a numeric 0 represented as a primitive 0 would also be rejected, though normal BigNumber objects are truthy.

Source

Thrown at src/core/operations/ToBase.mjs:46

            {
                "name": "Radix",
                "type": "number",
                "value": 36,
                "min": 2,
                "max": 36,
                "integer": true,
            }
        ];
    }

    /**
     * @param {BigNumber} input
     * @param {Object[]} args
     * @returns {string}
     */
    run(input, args) {
        if (!input) {
            throw new OperationError("Error: Input must be a number");
        }
        const radix = args[0];
        return input.toString(radix);
    }

}

export default ToBase;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Ensure the previous operation outputs a valid decimal number / BigNumber.
  2. Provide a concrete numeric input such as 255.
  3. If you genuinely need to convert 0, pass it as an explicit BigNumber object so it is truthy.

Example fix

// before: input = null            -> !input true -> throws
// after:  input = 255              -> converts to base 36 as '73'
Defensive patterns

Strategy: type-guard

Validate before calling

if (input === null || input === undefined || (typeof input === "number" && !Number.isFinite(input))) {
  throw new Error("To Base requires a numeric input");
}

Type guard

const hasNumericInput = v => v !== null && v !== undefined && !(typeof v === "number" && Number.isNaN(v));

Try / catch

try { toBase(input, radix); }
catch (e) { if (/Input must be a number/.test(e.message)) { input = new BigNumber(0); } else throw e; }

Prevention

When it happens

Trigger: Chaining To Base after an operation that yields null/undefined/empty instead of a BigNumber, or passing an input that the BigNumber layer could not materialise.

Common situations: A preceding conversion producing no number; a recipe where the input field is empty; a parsing step that silently returns null.

Related errors


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