{"record":{"id":"575cc1502f4fd013","repo":"jestjs/jest","slug":"seed-value-must-be-between-0x80000000-and-0x7f","errorCode":null,"errorMessage":"seed value must be between `-0x80000000` and `0x7fffffff` inclusive - instead it is ${newOptions.seed}","messagePattern":"seed value must be between `-0x80000000` and `0x7fffffff` inclusive - instead it is (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/jest-config/src/normalize.ts","lineNumber":1137,"sourceCode":"    newOptions.onlyChanged = newOptions.watch;\n  }\n\n  newOptions.randomize = newOptions.randomize || argv.randomize;\n\n  newOptions.showSeed =\n    newOptions.randomize || newOptions.showSeed || argv.showSeed;\n\n  const upperBoundSeedValue = 2 ** 31;\n\n  // bounds are determined by xoroshiro128plus which is used in v8 and is used here (at time of writing)\n  newOptions.seed =\n    argv.seed ??\n    Math.floor((2 ** 32 - 1) * Math.random() - upperBoundSeedValue);\n  if (\n    newOptions.seed < -upperBoundSeedValue ||\n    newOptions.seed > upperBoundSeedValue - 1\n  ) {\n    throw new ValidationError(\n      'Validation Error',\n      `seed value must be between \\`-0x80000000\\` and \\`0x7fffffff\\` inclusive - instead it is ${newOptions.seed}`,\n    );\n  }\n\n  if (!newOptions.onlyChanged) {\n    newOptions.onlyChanged = false;\n  }\n\n  if (!newOptions.lastCommit) {\n    newOptions.lastCommit = false;\n  }\n\n  if (!newOptions.onlyFailures) {\n    newOptions.onlyFailures = false;\n  }\n\n  if (!newOptions.watchAll) {","sourceCodeStart":1119,"sourceCodeEnd":1155,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-config/src/normalize.ts#L1119-L1155","documentation":"normalize() derives the seed (normalize.ts:1127-1141) for test randomization and validates it against the 32-bit signed integer range imposed by the xoroshiro128plus PRNG ([-2147483648, 2147483647]). argv.seed, when provided, must already lie in that range; anything outside throws a ValidationError because the PRNG output would be undefined/unreliable outside its domain.","triggerScenarios":"Passing jest --seed 9999999999 (exceeds 2^31-1); jest --seed -9999999999 (below -2^31); passing a float or a numeric string that yargs coerced out of range; computing a seed from a hash that overflowed.","commonSituations":"Reusing a seed reported by --showSeed from a tool that formatted it differently; CI passing a seed via env that exceeds the range; a script that derives the seed from a Git SHA truncated/expanded incorrectly.","solutions":["Constrain the seed to the signed 32-bit range: -2147483648 <= seed <= 2147483647.","If reproducing a prior run, copy the exact integer printed by --showSeed.","When deriving a seed programmatically, mask with & 0xffffffff and re-center, or use Math.floor(Math.random() * 2**32) - 2**31."],"exampleFix":"// before\njest --seed 9999999999\n// after\njest --seed 2147483647","handlingStrategy":"validation","validationCode":"const MIN = -0x80000000;\nconst MAX = 0x7fffffff;\nfunction clampSeed(seed: number): number {\n  if (!Number.isInteger(seed) || seed < MIN || seed > MAX) {\n    throw new Error(`seed must be an integer in [${MIN}, ${MAX}]`);\n  }\n  return seed;\n}\nfunction safeSeed(input: number): number {\n  // bring arbitrary input into range deterministically\n  return (input | 0); // truncate to int32, wraps within signed 32-bit range\n}","typeGuard":"function isInt32(n: unknown): n is number {\n  return typeof n === 'number' && Number.isInteger(n) && n >= -0x80000000 && n <= 0x7fffffff;\n}","tryCatchPattern":null,"preventionTips":["Copy the seed exactly from --showSeed output when reproducing a run.","When deriving seeds programmatically, mask into the signed 32-bit range (e.g. (val | 0)).","Validate env-provided seeds before forwarding to jest."],"tags":["jest-config","seed","randomize","validation","numeric-range"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}