[codex] fix: guard invalid web timestamps#3515
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved Defensive bug fix that guards timestamp formatting utilities against invalid date inputs. Changes are limited to returning empty strings/null instead of throwing or displaying NaN, with comprehensive test coverage for the new behavior. You can customize Macroscope's approvability policy. Learn more. |
39c8024 to
399d0fd
Compare
Dismissing prior approval to re-evaluate 1a4e9ee
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1a4e9ee. Configure here.
Dismissing prior approval to re-evaluate 00c2979
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
00c2979 to
dd3b03a
Compare

Summary
Root cause
Some future-time label helpers formatted input without first normalizing through the shared parser, so invalid strings could leak into date math.
Impact
Malformed timestamp values no longer break web timestamp labels.
Validation
PATH="$HOME/.vite-plus/bin:$PATH" vp test apps/web/src/timestampFormat.test.tsPATH="$HOME/.vite-plus/bin:$PATH" vp checkPATH="$HOME/.vite-plus/bin:$PATH" vp run typecheckNote
Low Risk
Defensive display-layer changes in timestamp utilities and settings labels only; no auth, persistence, or API behavior changes.
Overview
Hardens web timestamp formatting so malformed ISO strings no longer produce NaN-based labels or throw during
Intlformatting.A shared
parseTimestampDatehelper is introduced and wired through absolute, relative, elapsed, until, and expires-in formatters; invalid input now yields empty strings ornullinstead of bad output.getRelativeTimeStateadds a discriminated union (missing|invalid|relative) so UI can tell absent timestamps from corrupt ones.Diagnostics and provider “last checked” labels switch to that helper and show “Checked unavailable” when the timestamp is invalid, while still showing “Checking” / hiding when missing.
Reviewed by Cursor Bugbot for commit dd3b03a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Guard invalid web timestamps across all timestamp formatting functions
parseTimestampDateintimestampFormat.tsas a shared helper that returnsnullfor invalid ISO date strings, replacing ad-hoc date construction throughout the module.formatTimestamp,formatShortTimestamp,formatRelativeTime,formatElapsedDurationLabel,formatRelativeTimeUntil,formatExpiresInLabel, etc.) now return an empty string ornullon invalid input instead of computing from aNaNdate.getRelativeTimeState, a new function returning a discriminated union ('missing'|'invalid'|'relative') so UI components can distinguish between null and invalid timestamps.DiagnosticsLastCheckedandProviderLastCheckedcomponents to usegetRelativeTimeState, showing'Checked unavailable'for invalid timestamps instead of silently treating them as missing.Macroscope summarized dd3b03a.