{"record":{"id":"d1865d5e2b16c459","repo":"pbakaus/impeccable","slug":"warning-days-must-be-a-non-negative-number","errorCode":null,"errorMessage":"--warning-days must be a non-negative number.","messagePattern":"--warning-days must be a non-negative number\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/github/sheriff.mjs","lineNumber":450,"sourceCode":"    else if (arg === '--no-label-ensure') options.ensureLabels = false;\n    else if (arg === '--auto-close-regulars') options.autoCloseRegulars = true;\n    else if (arg === '--repo') options.repo = requireValue(argv, ++i, arg);\n    else if (arg === '--warning-days') options.warningDays = Number(requireValue(argv, ++i, arg));\n    else if (arg === '--close-days') options.closeDays = Number(requireValue(argv, ++i, arg));\n    else if (arg === '--maintainers') options.maintainers = splitList(requireValue(argv, ++i, arg));\n    else if (arg === '--regular-contributors') options.regularContributors = splitList(requireValue(argv, ++i, arg));\n    else if (arg === '--exempt-labels') options.exemptLabels = splitList(requireValue(argv, ++i, arg));\n    else if (arg === '--now') options.now = new Date(requireValue(argv, ++i, arg));\n    else if (arg === '--help' || arg === '-h') {\n      printHelp();\n      process.exit(0);\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n\n  if (!Number.isFinite(options.warningDays) || options.warningDays < 0) {\n    throw new Error('--warning-days must be a non-negative number.');\n  }\n  if (!Number.isFinite(options.closeDays) || options.closeDays < options.warningDays) {\n    throw new Error('--close-days must be at least --warning-days.');\n  }\n  if (Number.isNaN(options.now.getTime())) throw new Error('--now must be a valid date.');\n\n  return options;\n}\n\nfunction latestMaintainerWaitCommand(pr, maintainers) {\n  return latestDate([\n    ...(pr.comments || [])\n      .filter((comment) => maintainers.has(normalizeLogin(comment.authorLogin)))\n      .filter((comment) => hasSheriffWaitCommand(comment.body))\n      .map((comment) => comment.createdAt),\n    ...(pr.reviews || [])\n      .filter((review) => maintainers.has(normalizeLogin(review.authorLogin)))\n      .filter((review) => hasSheriffWaitCommand(review.body))","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/scripts/github/sheriff.mjs#L432-L468","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typo passing a unit suffix like '7d', a negative value, or a non-numeric env-derived value.","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."],"exampleFix":"# before\nnode sheriff.mjs --warning-days 7d\n\n# after\nnode sheriff.mjs --warning-days 7","handlingStrategy":"validation","validationCode":"function isValidWarningDays(value) {\n  const n = Number(value);\n  return Number.isFinite(n) && n >= 0;\n}","typeGuard":"function isNonNegativeDays(value) {\n  return Number.isFinite(Number(value)) && Number(value) >= 0;\n}","tryCatchPattern":"if (!isNonNegativeDays(warningDays)) {\n  console.error('--warning-days must be a non-negative number.');\n  process.exit(2);\n}","preventionTips":["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."],"tags":["cli","sheriff","validation","argv"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}