{"record":{"id":"4400bdbf5ac56a88","repo":"stablyai/orca","slug":"release-title-timestamp-is-invalid","errorCode":null,"errorMessage":"Release title timestamp is invalid.","messagePattern":"Release title timestamp is invalid\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/release-title-timestamp.mjs","lineNumber":14,"sourceCode":"const RELEASE_NAME_TIME_ZONE = 'America/Los_Angeles'\n\n/**\n * `Jul 31, 8:10PM` — the timestamp segment of a dev build's release title, shown\n * verbatim in both the GitHub releases list and the in-app build picker.\n *\n * Why Pacific while the tag's own stamp stays UTC: that stamp is a sort key, and\n * a local one would repeat an hour at every DST fall-back, making two distinct\n * builds compare equal. A title is only ever read, so it uses the timezone the\n * people reading it are in. The two therefore disagree by the current offset.\n */\nexport function formatReleaseTitleTimestamp(date) {\n  if (!(date instanceof Date) || Number.isNaN(date.getTime())) {\n    throw new Error('Release title timestamp is invalid.')\n  }\n  const parts = Object.fromEntries(\n    new Intl.DateTimeFormat('en-US', {\n      timeZone: RELEASE_NAME_TIME_ZONE,\n      month: 'short',\n      day: 'numeric',\n      hour: 'numeric',\n      minute: '2-digit',\n      hour12: true\n    })\n      .formatToParts(date)\n      .map((part) => [part.type, part.value])\n  )\n  // Assembled from parts rather than by string-editing the formatted output:\n  // recent ICU separates the time from AM/PM with U+202F, not a plain space, so\n  // a naive replace(' ', '') leaves the gap on some runtimes and not others.\n  return `${parts.month} ${parts.day}, ${parts.hour}:${parts.minute}${parts.dayPeriod.toUpperCase()}`\n}","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/release-title-timestamp.mjs#L1-L32","documentation":"Thrown by formatReleaseTitleTimestamp in config/scripts/release-title-timestamp.mjs when its `date` argument is not a Date instance, or is a Date whose time value is NaN (an Invalid Date). The function formats the timestamp segment of a dev-build release title (`Jul 31, 8:10PM`) in the America/Los_Angeles timezone via Intl.DateTimeFormat, which requires a valid Date. The guard at line 13-14 rejects anything else before formatToParts is called.","triggerScenarios":"Call formatReleaseTitleTimestamp with a string/number/null/undefined, or with `new Date('invalid')`, `new Date(undefined)`, or `new Date(NaN)`. `!(date instanceof Date)` catches non-Date inputs and `Number.isNaN(date.getTime())` catches Invalid Date instances.","commonSituations":"A caller passes a raw ISO string instead of `new Date(iso)`, forwards an undefined timestamp from a release object whose `created_at` was missing, or constructs a Date from a non-numeric source. The Invalid-Date case is the subtler one — `new Date(undefined)` produces an Invalid Date that passes instanceof but fails getTime().","solutions":["Pass a valid Date instance constructed from a known-good timestamp: `formatReleaseTitleTimestamp(new Date(release.created_at))`.","Guard the input at the call site: reject undefined/null before constructing the Date.","If the source value may be invalid, validate `!Number.isNaN(new Date(value).getTime())` before calling."],"exampleFix":"// before\nformatReleaseTitleTimestamp(release.created_at) // raw ISO string -> throws\n\n// after\nformatReleaseTitleTimestamp(new Date(release.created_at))","handlingStrategy":"type-guard","validationCode":"const d = date instanceof Date ? date : new Date(date)\nif (!(d instanceof Date) || Number.isNaN(d.getTime())) {\n  throw new Error('Cannot format release title: invalid timestamp')\n}\nreturn formatReleaseTitleTimestamp(d)","typeGuard":"function isValidReleaseDate(date) {\n  return date instanceof Date && !Number.isNaN(date.getTime())\n}","tryCatchPattern":null,"preventionTips":["Always construct a Date at the call site: `formatReleaseTitleTimestamp(new Date(value))`.","Reject undefined/null before constructing — `new Date(undefined)` is an Invalid Date.","Validate `!Number.isNaN(d.getTime())` on any Date built from untrusted input."],"tags":["release","date","validation","formatting"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}