sequelize/sequelize · error · RangeError
parseSafeInteger() radix argument must be between ${MIN_RADI
Error message
parseSafeInteger() radix argument must be between ${MIN_RADIX_INCLUSIVE} and ${MAX_RADIX_INCLUSIVE} What it means
Thrown at integer-regexp.ts:47 as a `RangeError` by getIsIntegerRegExp (the helper behind parseSafeInteger) when `radix` is below `MIN_RADIX_INCLUSIVE` (2) or above `MAX_RADIX_INCLUSIVE` (36). Radix must map onto the 36 available digit symbols (0-9, A-Z) defined at the top of the file, so anything outside [2,36] is rejected before building the digit-matching regex.
Source
Thrown at packages/utils/src/common/_internal/integer-regexp.ts:47
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
];
export const MAX_RADIX_INCLUSIVE = 36;
export const MIN_RADIX_INCLUSIVE = 2;
const integerRegExps: Array<RegExp | undefined> = Array.from({ length: numericSymbols.length });
export function getIsIntegerRegExp(radix: number): RegExp {
if (radix < MIN_RADIX_INCLUSIVE || radix > MAX_RADIX_INCLUSIVE) {
throw new RangeError(
`parseSafeInteger() radix argument must be between ${MIN_RADIX_INCLUSIVE} and ${MAX_RADIX_INCLUSIVE}`,
);
}
const existingRegExp = integerRegExps[radix];
if (existingRegExp) {
return existingRegExp;
}
/**
* Get all characters that are valid digits in this base (radix)
*
* Example: if radix = 16, characterSet will include [0, 1, ..., e, f]
*/
const characterSet = numericSymbols.slice(0, radix);
/**
* Construct a regex that matches whether the input is a valid integer in this radixView on GitHub (pinned to 7e1deec499)
Solutions
- Pass a radix in [2,36] — typically 10 for decimal or 16 for hex.
- If radix comes from input, validate it is an integer in range before passing.
- If you don't need a specific base, omit radix and let parseSafeInteger use its default.
Example fix
// before
parseSafeInteger(input, { radix: 1 });
// after
parseSafeInteger(input, { radix: 10 }); Defensive patterns
Strategy: validation
Validate before calling
const MIN_RADIX = 2, MAX_RADIX = 36;
if (!Number.isInteger(radix) || radix < MIN_RADIX || radix > MAX_RADIX) {
throw new RangeError(`radix must be an integer in [${MIN_RADIX}, ${MAX_RADIX}]`);
}
parseSafeInteger(input, { radix }); Type guard
function isValidRadix(r: unknown): r is number {
return typeof r === 'number' && Number.isInteger(r) && r >= 2 && r <= 36;
} Try / catch
try {
parseSafeInteger(input, { radix });
} catch (e) {
if (e instanceof RangeError && /radix/.test(e.message)) {
// fix or default the radix
} else throw e;
} Prevention
- Always validate radix is an integer in [2,36] before passing.
- Prefer the default radix when you don't need a specific base.
- Clamp or reject user-supplied radix values.
When it happens
Trigger: Calling `parseSafeInteger(str, { radix: 1 })`, `radix: 0`, `radix: 37`, or a negative number; passing a radix derived from unvalidated user input; radix computed to NaN/0 downstream.
Common situations: Off-by-one when clamping radix; confusing base-1 (unary, unsupported) with base-2; misreading Number.parseInt defaults.
Related errors
- This function can only clone plain objects, arrays and primi
- No value found for key: ${key}
- Invalid options: "to" and "step" cannot both be specified.
- Invalid options: "to" and "step" cannot both be specified.
- Validation encountered an unexpected error while validating
AI-assisted analysis of sequelize/sequelize@7e1deec499 (2026-08-03).
Data as JSON: /data/errors/0f389a8ac7b60820.json.
Report an issue: GitHub.