Skip to content

Fix Dag list filtering to include QUEUED DagRuns with null start_date #52668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 7, 2025

Conversation

choo121600
Copy link
Contributor

@choo121600 choo121600 commented Jul 1, 2025

Summary

This pull request fixes an inconsistency where Dags with queued DAG runs were correctly counted in the dashboard stats, but not shown in the Dag list page when using the last_dag_run_state=queued filter.

Why?

When users clicked on the "Queued Dags" stat in the dashboard, they were redirected to the Dag list view, but the page displayed "No Dag found" despite the presence of queued Dags.
This resulted in a confusing and inconsistent user experience between the dashboard and the list view.

Screen.Recording.2025-07-02.at.2.11.19.AM.mov

Additional context

The root cause appears to be related to Dags that are not "activated" in the UI — specifically, Dags with start_date = null (i.e., never scheduled), but were manually triggered and entered the queued state.
While these Dags have valid Dag runs in the queued state and are counted in the dashboard, the Dag list page excludes them due to how the filter is applied.
This PR adjusts the filtering logic so that the Dag list accurately reflects the Dags shown in the dashboard stats.

Screen.Recording.2025-07-02.at.4.31.05.AM.mov

Test Coverage

Added comprehensive unit tests for generate_dag_with_latest_run_query function to ensure proper handling of QUEUED DagRuns with start_date = null.

  • QUEUED runs inclusion: Verifies that DAGs with QUEUED state and null start_date are properly included in query results
  • JOIN behavior validation: Ensures DagRun data is correctly joined even when start_date is null
  • Sorting compatibility: Tests query behavior with different ordering options (last_run_state, last_run_start_date)
  • Latest run selection: Validates that the most recent DagRun is selected when multiple runs exist
  • Regression prevention: Prevents potential issues where null start_date values could cause DagRuns to be excluded

closes: #52655


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@choo121600 choo121600 changed the title Fix inconsistent queued DAG filtering between dashboard and list page Fix Dag list filtering to include QUEUED DagRuns with null start_date Jul 4, 2025
@choo121600 choo121600 requested a review from pierrejeambrun July 7, 2025 12:59
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, working as expected, just one suggestion.

@pierrejeambrun pierrejeambrun added the backport-to-v3-0-test Mark PR with this label to backport to v3-0-test branch label Jul 7, 2025
@pierrejeambrun pierrejeambrun merged commit 6f295a4 into apache:main Jul 7, 2025
101 checks passed
@choo121600 choo121600 deleted the dag-gen branch July 7, 2025 15:00
Copy link

github-actions bot commented Jul 7, 2025

Backport failed to create: v3-0-test. View the failure log Run details

Status Branch Result
v3-0-test Commit Link

You can attempt to backport this manually by running:

cherry_picker 6f295a4 v3-0-test

This should apply the commit to the v3-0-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

@pierrejeambrun
Copy link
Member

Whole bunch of commits to backport to be able to get that in, marking for 3.1.0.

HsiuChuanHsu pushed a commit to HsiuChuanHsu/airflow that referenced this pull request Jul 10, 2025
…apache#52668)

* Fix inconsistent queued DAG filtering between dashboard and list page

* Fix Dag list filtering to include DagRuns with null start_date

* Remove unnecessary @provide_session decorators from test_dags.py
stephen-bracken pushed a commit to stephen-bracken/airflow that referenced this pull request Jul 15, 2025
…apache#52668)

* Fix inconsistent queued DAG filtering between dashboard and list page

* Fix Dag list filtering to include DagRuns with null start_date

* Remove unnecessary @provide_session decorators from test_dags.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API backport-to-v3-0-test Mark PR with this label to backport to v3-0-test branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Queued Dag Count Between Dashboard and Dag List Page
2 participants