vincbeck commented on code in PR #37468:
URL: https://github.com/apache/airflow/pull/37468#discussion_r1491830495


##########
airflow/api_connexion/endpoints/import_error_endpoint.py:
##########
@@ -65,10 +85,42 @@ def get_import_errors(
     """Get all import errors."""
     to_replace = {"import_error_id": "id"}
     allowed_filter_attrs = ["import_error_id", "timestamp", "filename"]
-    total_entries = session.scalars(func.count(ImportErrorModel.id)).one()
+    count_query = select(func.count(ImportErrorModel.id))
     query = select(ImportErrorModel)
     query = apply_sorting(query, order_by, to_replace, allowed_filter_attrs)
+
+    can_read_all_dags = get_auth_manager().is_authorized_dag(method="GET")
+
+    if not can_read_all_dags:
+        # if the user doesn't have access to all DAGs, only display errors 
from visible DAGs
+        readable_dag_ids = security.get_readable_dags()
+        query = query.join(DagModel, DagModel.fileloc == 
ImportErrorModel.filename).where(
+            DagModel.dag_id.in_(readable_dag_ids)
+        )
+        count_query = count_query.join(DagModel, DagModel.fileloc == 
ImportErrorModel.filename).where(

Review Comment:
   From the query you cannot get the count? We are doing twice the same query 
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.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to