Lee-W commented on code in PR #47270:
URL: https://github.com/apache/airflow/pull/47270#discussion_r1995261869


##########
airflow/api_fastapi/core_api/routes/public/import_error.py:
##########
@@ -83,16 +131,48 @@ def get_import_errors(
         ),
     ],
     session: SessionDep,
+    user: GetUserDep,
 ) -> ImportErrorCollectionResponse:
     """Get all import errors."""
+    statement = select(ParseImportError)
     import_errors_select, total_entries = paginated_select(
-        statement=select(ParseImportError),
+        statement=statement,
         order_by=order_by,
         offset=offset,
         limit=limit,
         session=session,
     )
-    import_errors = session.scalars(import_errors_select)
+
+    auth_manager = get_auth_manager()
+    can_read_all_dags = auth_manager.is_authorized_dag(method="GET", user=user)
+    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 = auth_manager.get_permitted_dag_ids(method="GET", 
user=user)
+        dagfiles_stmt = 
select(DagModel.fileloc).distinct().where(DagModel.dag_id.in_(readable_dag_ids))
+        statement = 
statement.where(ParseImportError.filename.in_(dagfiles_stmt))
+        import_errors_select, total_entries = paginated_select(
+            statement=statement,
+            order_by=order_by,
+            offset=offset,
+            limit=limit,
+            session=session,
+        )

Review Comment:
   ```suggestion
       import_errors_select, total_entries = paginated_select(
           statement=statement,
           order_by=order_by,
           offset=offset,
           limit=limit,
           session=session,
       )
   ```



##########
airflow/api_fastapi/core_api/routes/public/import_error.py:
##########
@@ -83,16 +131,48 @@ def get_import_errors(
         ),
     ],
     session: SessionDep,
+    user: GetUserDep,
 ) -> ImportErrorCollectionResponse:
     """Get all import errors."""
+    statement = select(ParseImportError)
     import_errors_select, total_entries = paginated_select(

Review Comment:
   this can be removed



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