fix(code-browser): guard commit header against invalid commit date#1332
Open
jaso0n0818 wants to merge 1 commit into
Open
fix(code-browser): guard commit header against invalid commit date#1332jaso0n0818 wants to merge 1 commit into
jaso0n0818 wants to merge 1 commit into
Conversation
The repository code browser rendered the current commit's relative time with formatDistanceToNow(new Date(currentCommit.date), ...). date-fns throws 'RangeError: Invalid time value' on an Invalid Date, so a malformed or missing commit timestamp from the GitHub API crashed the whole code-browser panel. Route it through a small helper that returns '' for an unparseable date instead of throwing, so the header degrades gracefully.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The repository code browser renders the current commit's relative time with
formatDistanceToNow(new Date(currentCommit.date), ...). date-fns throwsRangeError: Invalid time valueon anInvalid Date, so a malformed or missing commit timestamp from the GitHub API crashes the entire code-browser panel.This routes the value through a small
commitRelativeTimehelper that returns''for an unparseable date instead of throwing, so the commit header degrades gracefully. (Companion to theformatDatehardening in the separate PR forsrc/utils/format.ts; this is the one directdate-fnscall in the code browser that bypasses that util.)Related Issues
No issue filed; self-contained crash hardening on API-sourced data. Pure logic change — the only visible difference is on malformed input (where it previously crashed), so no before/after media applies per CONTRIBUTING ("Pure logic changes … are exempt").
Type of Change
Testing
commitRelativeTime('2026-06-14T00:00:00Z')→ "in N months" (valid, unchanged);commitRelativeTime('N/A')/ missing →''(was: RangeError crash → now graceful).Checklist