pierrejeambrun commented on code in PR #72896:
URL: https://github.com/apache/airflow/pull/72896#discussion_r3981563977


##########
airflow-core/src/airflow/api_fastapi/core_api/security.py:
##########
@@ -228,7 +229,22 @@ def inner(
             )
         )
         if not dag_ids:
-            raise HTTPException(status.HTTP_404_NOT_FOUND, "File not found")
+            # A file with an import error has no registered Dags to authorize 
per-Dag against,
+            # so gate its reparse on the same permission that lets the caller 
view import errors.
+            has_import_error = session.scalar(
+                select(ParseImportError.id).where(
+                    ParseImportError.bundle_name == payload["bundle_name"],
+                    ParseImportError.filename == payload["relative_fileloc"],
+                )
+            )
+            if has_import_error is None:
+                raise HTTPException(status.HTTP_404_NOT_FOUND, "File not 
found")
+            _requires_access(
+                is_authorized_callback=lambda: 
get_auth_manager().authorize_view(
+                    access_view=AccessView.IMPORT_ERRORS, user=user
+                ),
+            )
+            return

Review Comment:
   This doesn't seem right



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