{"record":{"id":"e04cbd154c2b2910","repo":"gchq/CyberChef","slug":"error-radix-argument-must-be-between-2-and-36","errorCode":null,"errorMessage":"Error: Radix argument must be between 2 and 36","messagePattern":"Error: Radix argument must be between 2 and 36","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/FromBase.mjs","lineNumber":45,"sourceCode":"        this.outputType = \"BigNumber\";\n        this.args = [\n            {\n                \"name\": \"Radix\",\n                \"type\": \"number\",\n                \"value\": 36\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {BigNumber}\n     */\n    run(input, args) {\n        const radix = args[0];\n        if (radix < 2 || radix > 36) {\n            throw new OperationError(\"Error: Radix argument must be between 2 and 36\");\n        }\n\n        const number = input.replace(/\\s/g, \"\").split(\".\");\n        let result = new BigNumber(number[0], radix);\n\n        if (number.length === 1) return result;\n\n        // Fractional part\n        const radixBN = new BigNumber(radix);\n        for (let i = 0; i < number[1].length; i++) {\n            const digit = new BigNumber(number[1][i], radix);\n            result = result.plus(digit.div(radixBN.pow(i + 1)));\n        }\n\n        return result;\n    }\n\n}","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/FromBase.mjs#L27-L63","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set the Radix arg to a value between 2 and 36 inclusive.","For base 45/58/64/85, use the dedicated From Base45 / From Base58 / From Base64 / From Base85 operations instead.","Validate the radix value in your calling code before invoking."],"exampleFix":"// before: radix 64 (use the Base64 op instead)\nfromBase.run(input, [64]) // throws\n// after: valid radix\nfromBase.run(input, [36])","handlingStrategy":"validation","validationCode":"const radix = args[0];\nif (radix < 2 || radix > 36) {\n  // clamp or reject before calling fromBase.run()\n}","typeGuard":"function isValidRadix(r) {\n  return Number.isInteger(r) && r >= 2 && r <= 36;\n}","tryCatchPattern":"try {\n  fromBase.run(input, args);\n} catch (e) {\n  if (e.type === 'OperationError' && /Radix argument must be between/.test(e.message)) {\n    // fix the radix arg; use a dedicated op for base 45/58/64/85\n  } else throw e;\n}","preventionTips":["Constrain the Radix UI input to 2-36.","Use From Base45/58/64/85 for those bases, not From Base.","Validate programmatically-supplied radix before invoking."],"tags":["radix","bignumber","argument-validation","numeric"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}