jedcunningham commented on a change in pull request #17924:
URL: https://github.com/apache/airflow/pull/17924#discussion_r699499319



##########
File path: airflow/www/views.py
##########
@@ -678,18 +678,19 @@ def index(self):
                 for name, in dagtags
             ]
 
-            import_errors = 
session.query(errors.ImportError).order_by(errors.ImportError.id).all()
+            import_errors = 
session.query(errors.ImportError).order_by(errors.ImportError.id)
 
-        if import_errors:
-            dag_filenames = {dag.fileloc for dag in dags}
-            all_dags_readable = (permissions.ACTION_CAN_READ, 
permissions.RESOURCE_DAG) in user_permissions
+            if (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG) not in 
user_permissions:
+                # if the user doesn't have access to all DAGs, only display 
errors from visible DAGs
+                import_errors = import_errors.join(
+                    DagModel, DagModel.fileloc == errors.ImportError.filename
+                ).filter(DagModel.dag_id.in_(filter_dag_ids))
 
-            for import_error in import_errors:
-                if all_dags_readable or import_error.filename in dag_filenames:
-                    flash(
-                        "Broken DAG: [{ie.filename}] 
{ie.stacktrace}".format(ie=import_error),
-                        "dag_import_error",
-                    )
+        for import_error in import_errors:
+            flash(
+                "Broken DAG: [{ie.filename}] 
{ie.stacktrace}".format(ie=import_error),
+                "dag_import_error",
+            )

Review comment:
       ```suggestion
               for import_error in import_errors:
                   flash(
                       "Broken DAG: [{ie.filename}] 
{ie.stacktrace}".format(ie=import_error),
                       "dag_import_error",
                   )
   ```
   
   I'm thinking we now want to be in the create_session contextmanager now that 
we are lazily iterating?




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