Skip to content

[codex] fix: guard invalid web timestamps#3515

Open
StiensWout wants to merge 4 commits into
pingdotgg:mainfrom
StiensWout:staging/guard-invalid-web-timestamps
Open

[codex] fix: guard invalid web timestamps#3515
StiensWout wants to merge 4 commits into
pingdotgg:mainfrom
StiensWout:staging/guard-invalid-web-timestamps

Conversation

@StiensWout

@StiensWout StiensWout commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Guard web timestamp formatting paths so malformed timestamp strings return empty labels instead of crashing or rendering invalid output.
  • Reuse the existing timestamp parsing path across future-time helpers.

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.ts
  • PATH="$HOME/.vite-plus/bin:$PATH" vp check
  • PATH="$HOME/.vite-plus/bin:$PATH" vp run typecheck

Note

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 Intl formatting.

A shared parseTimestampDate helper is introduced and wired through absolute, relative, elapsed, until, and expires-in formatters; invalid input now yields empty strings or null instead of bad output. getRelativeTimeState adds 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

  • Introduces parseTimestampDate in timestampFormat.ts as a shared helper that returns null for invalid ISO date strings, replacing ad-hoc date construction throughout the module.
  • All formatting functions (formatTimestamp, formatShortTimestamp, formatRelativeTime, formatElapsedDurationLabel, formatRelativeTimeUntil, formatExpiresInLabel, etc.) now return an empty string or null on invalid input instead of computing from a NaN date.
  • Adds getRelativeTimeState, a new function returning a discriminated union ('missing' | 'invalid' | 'relative') so UI components can distinguish between null and invalid timestamps.
  • Updates DiagnosticsLastChecked and ProviderLastChecked components to use getRelativeTimeState, showing 'Checked unavailable' for invalid timestamps instead of silently treating them as missing.

Macroscope summarized dd3b03a.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 69482d42-58fc-4e36-84e4-4d343bd0e4d1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 23, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 23, 2026
@StiensWout StiensWout force-pushed the staging/guard-invalid-web-timestamps branch from 39c8024 to 399d0fd Compare June 23, 2026 05:45
Comment thread apps/web/src/timestampFormat.ts Outdated
@macroscopeapp macroscopeapp Bot dismissed their stale review June 23, 2026 05:56

Dismissing prior approval to re-evaluate 1a4e9ee

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/web/src/timestampFormat.ts
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 23, 2026
@macroscopeapp macroscopeapp Bot dismissed their stale review June 23, 2026 06:04

Dismissing prior approval to re-evaluate 00c2979

StiensWout and others added 4 commits June 23, 2026 19:19
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>
@StiensWout StiensWout force-pushed the staging/guard-invalid-web-timestamps branch from 00c2979 to dd3b03a Compare June 23, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant