github-advanced-security[bot] commented on code in PR #60112:
URL: https://github.com/apache/airflow/pull/60112#discussion_r2663756695


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py:
##########
@@ -372,45 +372,52 @@
 
     This endpoint allows specifying `~` as the dag_id to retrieve Dag Runs for 
all DAGs.
     """
-    query = select(DagRun).options(*eager_load_dag_run_for_validation())
+    try:
+        query = select(DagRun).options(*eager_load_dag_run_for_validation())
+
+        if dag_id != "~":
+            get_latest_version_of_dag(dag_bag, dag_id, session)  # Check if 
the DAG exists.
+            query = query.filter(DagRun.dag_id == dag_id).options()
+
+        # Add join with DagVersion if dag_version filter is active
+        if dag_version.value:
+            query = query.join(DagVersion, DagRun.created_dag_version_id == 
DagVersion.id)
+
+        dag_run_select, total_entries = paginated_select(
+            statement=query,
+            filters=[
+                run_after,
+                logical_date,
+                start_date_range,
+                end_date_range,
+                update_at_range,
+                duration_range,
+                conf_contains,
+                state,
+                run_type,
+                dag_version,
+                readable_dag_runs_filter,
+                run_id_pattern,
+                triggering_user_name_pattern,
+                dag_id_pattern,
+            ],
+            order_by=order_by,
+            offset=offset,
+            limit=limit,
+            session=session,
+        )
+        dag_runs = session.scalars(dag_run_select)
 
-    if dag_id != "~":
-        get_latest_version_of_dag(dag_bag, dag_id, session)  # Check if the 
DAG exists.
-        query = query.filter(DagRun.dag_id == dag_id).options()
+        return DAGRunCollectionResponse(
+            dag_runs=dag_runs,
+            total_entries=total_entries,
+        )
+    except Exception:
+        import traceback
 
-    # Add join with DagVersion if dag_version filter is active
-    if dag_version.value:
-        query = query.join(DagVersion, DagRun.created_dag_version_id == 
DagVersion.id)
+        from fastapi.responses import Response
 
-    dag_run_select, total_entries = paginated_select(
-        statement=query,
-        filters=[
-            run_after,
-            logical_date,
-            start_date_range,
-            end_date_range,
-            update_at_range,
-            duration_range,
-            conf_contains,
-            state,
-            run_type,
-            dag_version,
-            readable_dag_runs_filter,
-            run_id_pattern,
-            triggering_user_name_pattern,
-            dag_id_pattern,
-        ],
-        order_by=order_by,
-        offset=offset,
-        limit=limit,
-        session=session,
-    )
-    dag_runs = session.scalars(dag_run_select)
-
-    return DAGRunCollectionResponse(
-        dag_runs=dag_runs,
-        total_entries=total_entries,
-    )
+        return Response(status_code=500, content=traceback.format_exc())

Review Comment:
   ## Information exposure through an exception
   
   [Stack trace information](1) flows to this location and may be exposed to an 
external user.
   
   [Show more 
details](https://github.com/apache/airflow/security/code-scanning/562)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to