{"record":{"id":"aa1f187e4f75bfd5","repo":"pbakaus/impeccable","slug":"now-must-be-a-valid-date","errorCode":null,"errorMessage":"--now must be a valid date.","messagePattern":"--now must be a valid date\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/github/sheriff.mjs","lineNumber":455,"sourceCode":"    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))\n      .map((review) => review.submittedAt),\n  ]);\n}\n\nfunction currentDraftStartedAt(pr) {","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/scripts/github/sheriff.mjs#L437-L473","documentation":"Thrown by sheriff.mjs parseArgs when the --now value cannot be parsed into a valid Date (Date.getTime() returns NaN). The --now flag overrides the current time for stale-PR calculations, so an invalid date would break every comparison.","triggerScenarios":"Passing `--now not-a-date`, `--now 2025-13-99`, or any string the Date constructor cannot parse into a real instant.","commonSituations":"Date format mismatch (e.g. locale-specific string), a typo, or piping an empty variable into --now.","solutions":["Pass an ISO 8601 string: `--now 2025-08-12T00:00:00Z`.","If overriding for tests, generate the date programmatically to avoid format errors.","Leave --now unset to use the real current time."],"exampleFix":"# before\nnode sheriff.mjs --now 12/08/2025\n\n# after\nnode sheriff.mjs --now 2025-08-12T00:00:00Z","handlingStrategy":"validation","validationCode":"function isValidNow(value) {\n  if (!value) return true; // unset uses real now\n  const d = new Date(value);\n  return !Number.isNaN(d.getTime());\n}","typeGuard":"function isParsableDate(value) {\n  return !Number.isNaN(new Date(value).getTime());\n}","tryCatchPattern":"if (nowArg && !isParsableDate(nowArg)) {\n  console.error('--now must be a valid date.');\n  process.exit(2);\n}","preventionTips":["Pass ISO 8601 strings to --now to avoid locale parsing differences.","Generate --now programmatically in test harnesses rather than typing it.","Omit --now unless you specifically need to override the current time."],"tags":["cli","sheriff","validation","date","argv"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}