Fix commit list crash on out-of-range authored dates

What does this MR do and why?

The refactored Commit List does its date grouping and formatting client-side, where JavaScript's Date is bound by the ECMA-262 spec to years between roughly −271,821 and +275,760.

Git, however, stores commit timestamps as a signed 64-bit number with no such limit, so the GraphQL API can legitimately return dates outside that range (e.g. +292278994-08-17T07:12:55+00:00 on the spooky-stuff test branch).

When that happens, every formatter built on top of Date, Intl.DateTimeFormat, localeDateFormat, TimeagoTooltip, throws RangeError: Invalid time value and the whole page fails to render. The legacy view never hit this because dates were pre-formatted server-side by Ruby's Time.

This MR adds three minimal guards using the existing isValidDate helper so out-of-range dates fall back to the raw ISO string instead of crashing the page:

  • projects/commits/utils.js: groupCommitsByDay falls back to the raw authoredDate as
    the day key (otherwise unparseable dates silently collapse into a single "NaN-NaN-NaN" bucket).
  • commit_list_app.vue: getFormattedDate returns the raw input when new Date(...) is
    invalid, so the day-header <time> element keeps rendering.
  • commit_list_item.vue: <timeago-tooltip> is rendered conditionally; when the date is unparseable, a plain <span> with the raw string is shown in its place.

References

Issue: #591885 (closed)

Screenshots or screen recordings

Before After
Page fails to render — RangeError: Invalid time value Page renders; the spooky commit
shows its raw ISO timestamp inline
Screenshot_2026-04-30_at_08.57.26 Screenshot_2026-04-30_at_08.59.26

How to set up and validate locally

  1. Enabled Feature.enable(:project_commits_refactor)
  2. Navigate to the affected branch: (http://gdk.test:3000/gitlab-org/gitlab-test/-/commits/spooky-stuff)
  3. Before this MR: the page fails to render and the console shows RangeError: Invalid time value.
  4. After this MR: the page renders fully. The commit ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69 shows its raw +292278994-… timestamp inline; every other commit formats normally as Mon DD, YYYY
  5. with a working timeago tooltip.
  6. Toggle the feature flag off and confirm the legacy view still works as before (no regression).
Edited by Jacques Erasmus

Merge request reports

Loading
Loading