jestjs/jest · error · Error
PR number must be a positive integer, got: ${prNumber}
Error message
PR number must be a positive integer, got: ${prNumber} What it means
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.
Source
Thrown at scripts/checkChangelog.mjs:48
`${location}Expected org 'jestjs', got '${org}': ${match[0]}`,
);
}
if (type !== 'pull') {
errors.push(`${location}Expected 'pull', got '${type}': ${match[0]}`);
}
if (linkNumber !== urlNumber) {
errors.push(
`${location}Link number ${linkNumber} does not match URL number ${urlNumber}: ${match[0]}`,
);
}
}
++lineNumber;
}
}
if (prNumber != null) {
if (!/^[1-9]\d*$/.test(prNumber)) {
throw new Error(`PR number must be a positive integer, got: ${prNumber}`);
}
const mainChangelog = fs.readFileSync(mainChangelogPath, 'utf8');
const mainSection = mainChangelog
.split(/^## /m)
.find(s => s.startsWith('main\n'));
const expectedLink = `[#${prNumber}](https://github.com/jestjs/jest/pull/${prNumber})`;
if (mainSection == null || !mainSection.includes(expectedLink)) {
errors.push(
`${mainChangelogPath}: missing entry for PR #${prNumber} in "## main" — expected: ${expectedLink}`,
);
}
}
if (errors.length > 0) {
console.error(
`Found ${errors.length} error${
errors.length === 1 ? '' : 's'View on GitHub (pinned to f49721c78e)
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).
Example fix
// before node scripts/checkChangelog.mjs '#1234' node scripts/checkChangelog.mjs 0 // after node scripts/checkChangelog.mjs 1234
Defensive patterns
Strategy: validation
Validate before calling
function parsePrNumber(arg) {
if (arg == null) return undefined;
if (!/^[1-9]\d*$/.test(String(arg).trim())) {
throw new Error(`PR number must be a positive integer, got: ${arg}`);
}
return Number(arg);
} Type guard
function isPositiveInteger(v): boolean {
return /^[1-9]\d*$/.test(String(v).trim());
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- @jest/diff-sequences: ${name} typeof ${typeof arg} is not a
- @jest/diff-sequences: ${name} value ${arg} is not a safe int
- @jest/diff-sequences: ${name} value ${arg} is a negative int
- @jest/diff-sequences: ${name} typeof ${type} is not a functi
- any() expects to be passed a constructor function. Please pa
AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03).
Data as JSON: /data/errors/44753cfda3742660.json.
Report an issue: GitHub.