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


##########
tests/api_fastapi/core_api/routes/public/test_import_error.py:
##########
@@ -129,6 +140,53 @@ def test_get_import_error(
         }
         assert response.json() == expected_json
 
+    def test_should_raises_401_unauthenticated(self, 
unauthenticated_test_client, setup):
+        import_error_id = setup[FILENAME1].id

Review Comment:
   It is not actually something introduced in this PR, but `setup` should 
probably be refactored into the fixture. it's quite unreadable now.



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

Review Comment:
   Do you think we can also select DagModel.id here so that we don't need to 
select again in line 165?



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