diff --git a/airflow/www/static/js/dag/details/gantt/GanttTooltip.tsx b/airflow/www/static/js/dag/details/gantt/GanttTooltip.tsx index 2f501209256d4..465eaa930e957 100644 --- a/airflow/www/static/js/dag/details/gantt/GanttTooltip.tsx +++ b/airflow/www/static/js/dag/details/gantt/GanttTooltip.tsx @@ -34,9 +34,11 @@ const GanttTooltip = ({ task, instance }: Props) => { // Calculate durations in ms const taskDuration = getDuration(instance?.startDate, instance?.endDate); - const queuedDuration = instance?.queuedDttm - ? getDuration(instance.queuedDttm, instance?.startDate) - : 0; + const queuedDuration = + instance?.queuedDttm && + (instance?.startDate ? instance.queuedDttm < instance.startDate : true) + ? getDuration(instance.queuedDttm, instance?.startDate) + : 0; return ( diff --git a/airflow/www/static/js/dag/details/gantt/Row.tsx b/airflow/www/static/js/dag/details/gantt/Row.tsx index bf1ce7ac60a25..8d58eff613d2c 100644 --- a/airflow/www/static/js/dag/details/gantt/Row.tsx +++ b/airflow/www/static/js/dag/details/gantt/Row.tsx @@ -53,17 +53,21 @@ const Row = ({ const instance = task.instances.find((ti) => ti.runId === runId); const isSelected = taskId === instance?.taskId; const hasQueuedDttm = !!instance?.queuedDttm; + const validQueuedDttm = + hasQueuedDttm && + (instance?.startDate && instance?.queuedDttm + ? instance.queuedDttm < instance.startDate + : true); const isOpen = openGroupIds.includes(task.id || ""); // Calculate durations in ms const taskDuration = getDuration(instance?.startDate, instance?.endDate); - const queuedDuration = hasQueuedDttm + const queuedDuration = validQueuedDttm ? getDuration(instance?.queuedDttm, instance?.startDate) : 0; - const taskStartOffset = getDuration( - ganttStartDate, - instance?.queuedDttm || instance?.startDate - ); + const taskStartOffset = validQueuedDttm + ? getDuration(ganttStartDate, instance?.queuedDttm || instance?.startDate) + : getDuration(ganttStartDate, instance?.startDate); // Percent of each duration vs the overall dag run const taskDurationPercent = taskDuration / runDuration; @@ -74,8 +78,8 @@ const Row = ({ // Min width should be 5px let width = ganttWidth * taskDurationPercent; if (width < 5) width = 5; - let queuedWidth = hasQueuedDttm ? ganttWidth * queuedDurationPercent : 0; - if (hasQueuedDttm && queuedWidth < 5) queuedWidth = 5; + let queuedWidth = validQueuedDttm ? ganttWidth * queuedDurationPercent : 0; + if (validQueuedDttm && queuedWidth < 5) queuedWidth = 5; const offsetMargin = taskStartOffsetPercent * ganttWidth; return (