From 5ae48ab67fda155364f507866d4c02526396a55e Mon Sep 17 00:00:00 2001 From: Vishwaspatel2401 Date: Sat, 11 Jul 2026 15:39:37 -0700 Subject: [PATCH] Fix DAG details active runs count to exclude queued runs --- airflow-core/newsfragments/69769.bugfix.rst | 1 + .../src/airflow/api_fastapi/core_api/routes/public/dags.py | 2 +- .../tests/unit/api_fastapi/core_api/routes/public/test_dags.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 airflow-core/newsfragments/69769.bugfix.rst diff --git a/airflow-core/newsfragments/69769.bugfix.rst b/airflow-core/newsfragments/69769.bugfix.rst new file mode 100644 index 0000000000000..696ca644626bf --- /dev/null +++ b/airflow-core/newsfragments/69769.bugfix.rst @@ -0,0 +1 @@ +Fix DAG details 'active runs' count to only include running runs, not queued ones, matching scheduler enforcement of max_active_runs diff --git a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py index 355ce4ca7a5e7..69b6b2932f095 100644 --- a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py +++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py @@ -250,7 +250,7 @@ def get_dag_details( session.scalar( select(func.count()) .select_from(DagRun) - .where(DagRun.dag_id == dag_id, DagRun.state.in_([DagRunState.RUNNING, DagRunState.QUEUED])) + .where(DagRun.dag_id == dag_id, DagRun.state == DagRunState.RUNNING) ) or 0 ) diff --git a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py index 4831394c45bf1..f47d6f54c2a8a 100644 --- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py +++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py @@ -1278,7 +1278,7 @@ def test_dag_details_includes_active_runs_count(self, session, test_client): # Verify active_runs_count field is present and correct assert "active_runs_count" in body assert isinstance(body["active_runs_count"], int) - assert body["active_runs_count"] == 2 # 1 running + 1 queued + assert body["active_runs_count"] == 1 # only running counts, queued does not # Test with DAG that has no active runs response = test_client.get(f"/dags/{DAG1_ID}/details")