ashb commented on a change in pull request #10594:
URL: https://github.com/apache/airflow/pull/10594#discussion_r492218992



##########
File path: airflow/api_connexion/endpoints/dag_run_endpoint.py
##########
@@ -158,26 +158,29 @@ def _apply_date_filters_to_query(
     return query
 
 
[email protected]_authentication
[email protected]_access([("can_read", "Dag"), ("can_read", "DagRun")])
 @provide_session
 def get_dag_runs_batch(session):
     """
     Get list of DAG Runs
     """
     body = request.get_json()
-    try:
+    try:  # TODO: Handle filtering.
         data = dagruns_batch_form_schema.load(body)
     except ValidationError as err:
         raise BadRequest(detail=str(err.messages))
 
+    appbuilder = current_app.appbuilder
+    readable_dag_ids = appbuilder.sm.get_readable_dag_ids(g.user)
     query = session.query(DagRun)
-
-    if data["dag_ids"]:
-        query = query.filter(DagRun.dag_id.in_(data["dag_ids"]))
+    if data.get("dag_ids"):
+        dag_ids = set(data["dag_ids"]) & set(readable_dag_ids)
+        query = query.filter(DagRun.dag_id.in_(dag_ids))
+    else:
+        query = query.filter(DagRun.dag_id.in_(readable_dag_ids))
 
     dag_runs, total_entries = _fetch_dag_runs(
         query,
-        session,

Review comment:
       What was the reason for removing the session here?




----------------------------------------------------------------
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.

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


Reply via email to