Fix Gantt view "Error invalid date" on running DagRun#64752
Fix Gantt view "Error invalid date" on running DagRun#64752bbovenzi merged 7 commits intoapache:mainfrom
Conversation
834aa1d to
23de8f9
Compare
PR description doesn't match the actual diffThe description claims five changes, but the diff only modifies 4 lines in
The only actual changes in this PR are:
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 |
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
3e376da to
3069c03
Compare
…4752) * Fix Gantt view "Error invalid date" on running DagRun (#64599) 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. * Address review feedback: fix static checks and consistency - 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) * Fix ESLint no-empty-function error in Gantt utils test * Fix TypeScript type errors in Gantt utils tests 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 * Fix translate type to use TFunction in Gantt utils tests (cherry picked from commit 0b2efb9) Co-authored-by: Ashir Alam <alamashir@gmail.com>
Backport successfully created: v3-2-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…ache#64752) * Fix Gantt view "Error invalid date" on running DagRun (apache#64599) 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. * Address review feedback: fix static checks and consistency - 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) * Fix ESLint no-empty-function error in Gantt utils test * Fix TypeScript type errors in Gantt utils tests 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 * Fix translate type to use TFunction in Gantt utils tests (cherry picked from commit 0b2efb9) Co-authored-by: Ashir Alam <alamashir@gmail.com>
…4752) (#64853) * Fix Gantt view "Error invalid date" on running DagRun (#64599) 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. * Address review feedback: fix static checks and consistency - 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) * Fix ESLint no-empty-function error in Gantt utils test * Fix TypeScript type errors in Gantt utils tests 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 * Fix translate type to use TFunction in Gantt utils tests (cherry picked from commit 0b2efb9) Co-authored-by: Ashir Alam <alamashir@gmail.com>

Summary
Fixes #64599
The Gantt chart's x-axis scale min/max calculation used
new Date().getTime()to parse date strings. SincetransformGanttDataoutputs ISO strings viadayjs().toISOString(), this worked in most cases, butnew Date()parsing is not guaranteed by the ECMAScript spec for all formats and can returnNaNin edge cases, crashing Chart.js's time scale with "Error invalid date".Changes
new Date(...).getTime()withdayjs(...).valueOf()in the x-axis scale min and max calculations for consistent, reliable date parsingcreateChartOptionsscale calculations (completed tasks, running tasks, empty data fallback) andtransformGanttData(null start_date filtering, running task end time, null group dates, ISO string validity)Test plan