pbakaus/impeccable · error · Error
--warning-days must be a non-negative number.
Error message
--warning-days must be a non-negative number.
What it means
Thrown by sheriff.mjs parseArgs after flag parsing when --warning-days is not a finite number or is negative. The default is 7 days; an invalid value would corrupt the warning schedule.
Source
Thrown at scripts/github/sheriff.mjs:450
else if (arg === '--no-label-ensure') options.ensureLabels = false;
else if (arg === '--auto-close-regulars') options.autoCloseRegulars = true;
else if (arg === '--repo') options.repo = requireValue(argv, ++i, arg);
else if (arg === '--warning-days') options.warningDays = Number(requireValue(argv, ++i, arg));
else if (arg === '--close-days') options.closeDays = Number(requireValue(argv, ++i, arg));
else if (arg === '--maintainers') options.maintainers = splitList(requireValue(argv, ++i, arg));
else if (arg === '--regular-contributors') options.regularContributors = splitList(requireValue(argv, ++i, arg));
else if (arg === '--exempt-labels') options.exemptLabels = splitList(requireValue(argv, ++i, arg));
else if (arg === '--now') options.now = new Date(requireValue(argv, ++i, arg));
else if (arg === '--help' || arg === '-h') {
printHelp();
process.exit(0);
} else {
throw new Error(`Unknown argument: ${arg}`);
}
}
if (!Number.isFinite(options.warningDays) || options.warningDays < 0) {
throw new Error('--warning-days must be a non-negative number.');
}
if (!Number.isFinite(options.closeDays) || options.closeDays < options.warningDays) {
throw new Error('--close-days must be at least --warning-days.');
}
if (Number.isNaN(options.now.getTime())) throw new Error('--now must be a valid date.');
return options;
}
function latestMaintainerWaitCommand(pr, maintainers) {
return latestDate([
...(pr.comments || [])
.filter((comment) => maintainers.has(normalizeLogin(comment.authorLogin)))
.filter((comment) => hasSheriffWaitCommand(comment.body))
.map((comment) => comment.createdAt),
...(pr.reviews || [])
.filter((review) => maintainers.has(normalizeLogin(review.authorLogin)))
.filter((review) => hasSheriffWaitCommand(review.body))View on GitHub (pinned to d14711ae3d)
Solutions
- Pass a non-negative integer: `--warning-days 7`.
- Strip unit suffixes before passing; sheriff takes a bare number of days.
- If deriving from an env var, validate and coerce it upstream.
Example fix
# before node sheriff.mjs --warning-days 7d # after node sheriff.mjs --warning-days 7
Defensive patterns
Strategy: validation
Validate before calling
function isValidWarningDays(value) {
const n = Number(value);
return Number.isFinite(n) && n >= 0;
} Type guard
function isNonNegativeDays(value) {
return Number.isFinite(Number(value)) && Number(value) >= 0;
} Try / catch
if (!isNonNegativeDays(warningDays)) {
console.error('--warning-days must be a non-negative number.');
process.exit(2);
} Prevention
- Pass bare integers (no unit suffixes) to day-based flags.
- Validate env-derived numbers before they reach the CLI.
- Add a unit test asserting non-numeric values are rejected.
When it happens
Trigger: Passing `--warning-days abc` (NaN after Number()), `--warning-days -1`, or `--warning-days` with a non-numeric value. Number() accepts the string so the parse does not fail, but the post-loop finite/negative check does.
Common situations: Typo passing a unit suffix like '7d', a negative value, or a non-numeric env-derived value.
Related errors
- Unknown argument: ${arg}
- --close-days must be at least --warning-days.
- --now must be a valid date.
- ${flag} requires a value.
- --target requires a path value (use --target <path> or --tar
AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13).
Data as JSON: /api/errors/d1865d5e2b16c459.
Report an issue: GitHub.