Skip to content

Fix Gantt view "Error invalid date" on running DagRun#64752

Draft
alamashir wants to merge 5 commits intoapache:mainfrom
alamashir:fix/gantt-invalid-date-running-dagrun
Draft

Fix Gantt view "Error invalid date" on running DagRun#64752
alamashir wants to merge 5 commits intoapache:mainfrom
alamashir:fix/gantt-invalid-date-running-dagrun

Conversation

@alamashir
Copy link
Copy Markdown
Contributor

@alamashir alamashir commented Apr 6, 2026

Summary

Fixes #64599

The Gantt chart's x-axis scale min/max calculation used new Date().getTime() to parse date strings. Since transformGanttData outputs ISO strings via dayjs().toISOString(), this worked in most cases, but new Date() parsing is not guaranteed by the ECMAScript spec for all formats and can return NaN in edge cases, crashing Chart.js's time scale with "Error invalid date".

Changes

  • Replace new Date(...).getTime() with dayjs(...).valueOf() in the x-axis scale min and max calculations for consistent, reliable date parsing
  • Add unit tests for createChartOptions scale calculations (completed tasks, running tasks, empty data fallback) and transformGanttData (null start_date filtering, running task end time, null group dates, ISO string validity)

Test plan

  • All 186 existing UI tests pass
  • 7 new unit tests added and passing
  • Manual verification: trigger a DAG run, open grid view, enable "Show Gantt" while the run is still in progress — should render without error
  • Manual verification: Gantt chart for completed DagRuns still works correctly
  • Manual verification: tooltip shows correct start/end dates and duration

@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Apr 6, 2026
@alamashir alamashir force-pushed the fix/gantt-invalid-date-running-dagrun branch from 834aa1d to 23de8f9 Compare April 6, 2026 02:37
@shivaam
Copy link
Copy Markdown
Contributor

shivaam commented Apr 6, 2026

Seems like you missed manual testing in the pr description. Please confirm if manual verification was completed.
image

@shivaam
Copy link
Copy Markdown
Contributor

shivaam commented Apr 6, 2026

PR description doesn't match the actual diff

The description claims five changes, but the diff only modifies 4 lines in utils.ts (swapping new Date().getTime()dayjs().valueOf()) plus a new test file. Three of the listed changes are not part of this PR — they already exist on main:

  • Store raw ISO date strings from the API in the data array instead of pre-formatted display strings — formatting now only happens at display time (tooltips, tick labels)
  • Skip tasks/groups where start_date is null (task hasn't started, no meaningful bar to show)
  • Handle running groups by using current time as end date when max_end_date is null

transformGanttData on main already:

  • Outputs ISO strings via dayjs(...).toISOString() (not pre-formatted display strings)
  • Filters out tasks with null start_date (.filter((tryInstance) => tryInstance.start_date !== null))
  • Returns undefined for groups where min_start_date === null || max_end_date === null

The only actual changes in this PR are:

  1. Replacing new Date(...).getTime() with dayjs(...).valueOf() in the x-axis scale min/max calculations
  2. Adding unit tests

Could you update the description to accurately reflect what this PR changes?

Also noting the inconsistent null handling between the two scale blocks — in the max calculation you use dayjs(item.x[1] ?? undefined) but in the min calculation you use dayjs(item.x[1]) without the fallback. This should be consistent.

@alamashir alamashir marked this pull request as draft April 6, 2026 04:02
The Gantt chart scale calculation used new Date() to parse date strings,
which fails for non-UTC timezone abbreviations, returning NaN and
crashing Chart.js's time scale.

Changes:
- Replace new Date().getTime() with dayjs().valueOf() for reliable date
  parsing in the x-axis scale min/max calculations.
- Add unit tests for Gantt chart scale calculations and data
  transformation covering completed tasks, running tasks with null end
  dates, groups with null dates, and ISO date string validity.
- Fix object property ordering in test data (alphabetical)
- Import vi as type-only from vitest
- Fix duration field position in selectedRun objects
- Make dayjs null handling consistent between max and min scale
  calculations (remove unnecessary ?? undefined)
Update test fixtures to match current generated types:
- Add has_missed_deadline to GridRunsResponse objects
- Remove dag_id and map_index from GanttTaskInstance objects
- Add depth to GridTask objects
- Add task_display_name to LightGridTaskInstanceSummary objects
@alamashir alamashir force-pushed the fix/gantt-invalid-date-running-dagrun branch from 3e376da to 3069c03 Compare April 6, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gantt view gives "Error invalid date" on DagRun in running state

2 participants