{"id":"44753cfda3742660","repo":"jestjs/jest","slug":"pr-number-must-be-a-positive-integer-got-prnum","errorCode":null,"errorMessage":"PR number must be a positive integer, got: ${prNumber}","messagePattern":"PR number must be a positive integer, got: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/checkChangelog.mjs","lineNumber":48,"sourceCode":"          `${location}Expected org 'jestjs', got '${org}': ${match[0]}`,\n        );\n      }\n      if (type !== 'pull') {\n        errors.push(`${location}Expected 'pull', got '${type}': ${match[0]}`);\n      }\n      if (linkNumber !== urlNumber) {\n        errors.push(\n          `${location}Link number ${linkNumber} does not match URL number ${urlNumber}: ${match[0]}`,\n        );\n      }\n    }\n    ++lineNumber;\n  }\n}\n\nif (prNumber != null) {\n  if (!/^[1-9]\\d*$/.test(prNumber)) {\n    throw new Error(`PR number must be a positive integer, got: ${prNumber}`);\n  }\n\n  const mainChangelog = fs.readFileSync(mainChangelogPath, 'utf8');\n  const mainSection = mainChangelog\n    .split(/^## /m)\n    .find(s => s.startsWith('main\\n'));\n  const expectedLink = `[#${prNumber}](https://github.com/jestjs/jest/pull/${prNumber})`;\n  if (mainSection == null || !mainSection.includes(expectedLink)) {\n    errors.push(\n      `${mainChangelogPath}: missing entry for PR #${prNumber} in \"## main\" — expected: ${expectedLink}`,\n    );\n  }\n}\n\nif (errors.length > 0) {\n  console.error(\n    `Found ${errors.length} error${\n      errors.length === 1 ? '' : 's'","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/scripts/checkChangelog.mjs#L30-L66","documentation":"scripts/checkChangelog.mjs reads process.argv[2] as an optional PR number. At checkChangelog.mjs:46-49, if a value was supplied it must match /^[1-9]\\d*$/ (a positive integer with no leading zero, no sign). Anything else — 'abc', '0', '-5', '1.5', '' — throws before any changelog verification runs.","triggerScenarios":"Invoking `node scripts/checkChangelog.mjs <arg>` with a non-positive-integer argument: a typo, a copy-pasted PR URL fragment, '0', a negative number, a decimal, or an empty string.","commonSituations":"CI passing the PR number through an env/arg that is unset (empty), formatted with a '#', taken from a URL slug, or a script that interpolates the number with extra whitespace/sign characters.","solutions":["Pass the bare numeric PR number with no leading zero or sign: `node scripts/checkChangelog.mjs 12345`.","If the value comes from CI, strip '#', whitespace, and URL parts before invoking, and ensure it is set.","Omit the argument entirely to skip the PR-specific check (only changelog link format is then validated)."],"exampleFix":"// before\nnode scripts/checkChangelog.mjs '#1234'\nnode scripts/checkChangelog.mjs 0\n// after\nnode scripts/checkChangelog.mjs 1234","handlingStrategy":"validation","validationCode":"function parsePrNumber(arg) {\n  if (arg == null) return undefined;\n  if (!/^[1-9]\\d*$/.test(String(arg).trim())) {\n    throw new Error(`PR number must be a positive integer, got: ${arg}`);\n  }\n  return Number(arg);\n}","typeGuard":"function isPositiveInteger(v): boolean {\n  return /^[1-9]\\d*$/.test(String(v).trim());\n}","tryCatchPattern":null,"preventionTips":["Pass the bare PR number with no '#', sign, or leading zero.","In CI, sanitize the PR value (strip '#', whitespace, URL fragments) before forwarding it as argv.","Omit the argument entirely when you only want the changelog link-format checks."],"tags":["ci","changelog","validation","cli-args","build"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}