henry3260 commented on code in PR #69790:
URL: https://github.com/apache/airflow/pull/69790#discussion_r3571298575


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/import_error.py:
##########
@@ -159,6 +173,31 @@ def get_import_errors(
     # Subquery for files that have any Dags
     files_with_any_dags = 
select(DagModel.relative_fileloc).distinct().subquery()

Review Comment:
   ```suggestion
       files_with_any_dags = select(DagModel.relative_fileloc, 
DagModel.bundle_name,).distinct().subquery()
   ```



##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/import_error.py:
##########
@@ -159,6 +173,31 @@ def get_import_errors(
     # Subquery for files that have any Dags
     files_with_any_dags = 
select(DagModel.relative_fileloc).distinct().subquery()
 
+    # Import errors for files that have **no** registered Dag have no per-Dag
+    # key to authorize on. Authorize them on the dedicated 
``IMPORT_ERRORS_ALL``
+    # view (admin by default), scoped to the file's team via its bundle, and
+    # keep only the ones the caller may see. Filtering here (rather than
+    # redacting in the loop) also excludes unauthorized rows from the count and
+    # pagination, so their existence -- and, for team-scoped bundles, the
+    # cross-team file/bundle names -- does not leak.
+    unregistered_errors = session.execute(
+        select(ParseImportError.id, ParseImportError.bundle_name)
+        .outerjoin(files_with_any_dags, ParseImportError.filename == 
files_with_any_dags.c.relative_fileloc)

Review Comment:
   ```suggestion
           .outerjoin(
               files_with_any_dags,
               (ParseImportError.filename == 
files_with_any_dags.c.relative_fileloc)
               & (ParseImportError.bundle_name == 
files_with_any_dags.c.bundle_name),
           )
   ```
   



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