{"record":{"id":"77959774d7167874","repo":"Hmbown/CodeWhale","slug":"github-label-timestamp-is-invalid-value","errorCode":null,"errorMessage":"GitHub ${label} timestamp is invalid: ${value}","messagePattern":"GitHub (.+?) timestamp is invalid: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"npm/codewhale/scripts/verify-release-assets.js","lineNumber":261,"sourceCode":"    }\n  }\n\n  if (orderedCandidates.length === 0) {\n    throw new Error(\n      `No release.yml workflow run found for ${tag} at ${tagSha}. ` +\n        \"Rerun the Release workflow before publishing npm, or increase the verifier's last-100-runs search window.\",\n    );\n  }\n  throw new Error(\n    `No successful asset-publishing job found in release.yml workflow runs for ${tag} at ${tagSha}. ` +\n      \"Repair the Release workflow before publishing npm.\",\n  );\n}\n\nfunction parseGitHubTime(value, label) {\n  const timestamp = Date.parse(value);\n  if (!Number.isFinite(timestamp)) {\n    throw new Error(`GitHub ${label} timestamp is invalid: ${value}`);\n  }\n  return timestamp;\n}\n\nfunction assertReleaseAssetsFresh(release, expectedAssets, run) {\n  const assetsByName = new Map((release.assets || []).map((asset) => [asset.name, asset]));\n  const missing = expectedAssets.filter((asset) => !assetsByName.has(asset));\n  if (missing.length > 0) {\n    throw new Error(`GitHub Release is missing required release asset(s): ${missing.join(\", \")}`);\n  }\n\n  // #5429: compare against the successful release job's started_at when the\n  // run record carries it; fall back to the run-level timestamp only when a\n  // job baseline is unavailable.\n  const baseline = run.release_job_started_at || run.run_started_at || run.created_at;\n  const baselineLabel = run.release_job_started_at ? \"release job start\" : \"workflow run start\";\n  const freshnessBaseline = parseGitHubTime(baseline, baselineLabel);\n  const stale = [];","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/npm/codewhale/scripts/verify-release-assets.js#L243-L279","documentation":"Strict timestamp parsing in the release-asset verifier: Date.parse returned NaN for the given GitHub ${label} field (created/updated time from an API response). GitHub timestamps are ISO-8601; a non-finite parse means the API returned a missing, malformed, or truncated date, and the freshness check cannot proceed safely.","triggerScenarios":"Any timestamp passed to parseGitHubTime (asset updated_at/created_at, run started_at, release created_at) that is undefined, empty, or not parseable by Date.parse.","commonSituations":"A run record lacking started_at/created_at; a mocked or hand-built response object missing date fields; clock/locale anomalies in locally constructed test data.","solutions":["Print the offending record and confirm the date field exists and is ISO 8601.","Ensure the release job's started_at is populated (rerun the workflow if the run record is incomplete).","If you inject API fixtures, include valid RFC 3339 timestamps."],"exampleFix":"// before\n{ database_id: 42 }\n// after\n{ database_id: 42, run_started_at: \"2026-09-15T00:00:00Z\" }","handlingStrategy":"validation","validationCode":"for (const t of [run.run_started_at, release.created_at]) { if (!t || Number.isNaN(Date.parse(t))) throw new Error(`Missing/invalid timestamp: ${t}`); }","typeGuard":"const isIsoTimestamp = (v) => typeof v === \"string\" && Number.isFinite(Date.parse(v));","tryCatchPattern":"try { verifyFreshness(release, expected, run); } catch (e) { if (e.message.startsWith(\"GitHub \") && e.message.includes(\"timestamp is invalid\")) { console.error(\"API record missing a valid date; refetch or rerun the workflow.\"); } else throw e; }","preventionTips":["Never construct API fixtures without RFC 3339 timestamps","Check that workflow run records include started_at","Log the raw record when timestamp parsing fails"],"tags":["github-api","timestamps","validation"],"backgroundTag":"invalid-date-format","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}