This is an automated email from the ASF dual-hosted git repository.

rahulvats pushed a commit to branch v3-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 78ecb8609ee1fc503f397c119afa1f4690fdf6b8
Author: Pierre Jeambrun <[email protected]>
AuthorDate: Thu Mar 26 13:16:16 2026 +0100

    Fix dag_display_name property bypass for DagStats query (#64256)
    
    (cherry picked from commit 63be7a6be9b9d56bf2e1b341588be82e6f1e7905)
---
 airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py 
b/airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py
index 72565c45ef2..f9ae3d6c3b6 100644
--- a/airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py
+++ b/airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py
@@ -35,15 +35,18 @@ from airflow.models.taskinstancehistory import 
TaskInstanceHistory
 if TYPE_CHECKING:
     from sqlalchemy.orm import Session
 
+# Use the hybrid_property for dag_display_name so the CASE WHEN fallback to 
dag_id
+# is applied when dag_display_name is NULL.  Using __table__.c would return 
raw NULLs
+# and crash DagStatsResponse validation 
(https://github.com/apache/airflow/issues/64247).
 dagruns_select_with_state_count = (
-    select(
+    select(  # type: ignore[call-overload]
         DagRun.__table__.c.dag_id,
         DagRun.__table__.c.state,
-        DagModel.__table__.c.dag_display_name,
+        DagModel.dag_display_name,
         func.count(DagRun.__table__.c.state).label("count"),
     )
     .join(DagModel, DagRun.__table__.c.dag_id == DagModel.__table__.c.dag_id)
-    .group_by(DagRun.__table__.c.dag_id, DagRun.__table__.c.state, 
DagModel.__table__.c.dag_display_name)
+    .group_by(DagRun.__table__.c.dag_id, DagRun.__table__.c.state, 
DagModel.dag_display_name)
     .order_by(DagRun.__table__.c.dag_id)
 )
 

Reply via email to