Zi-Yi-Ming commented on code in PR #77717:
URL: https://github.com/apache/airflow/pull/77717#discussion_r4726674994


##########
airflow-core/src/airflow/cli/commands/dag_command.py:
##########
@@ -672,9 +673,26 @@ def dag_details(args, *, session: Session = NEW_SESSION):
 @provide_session
 def dag_list_import_errors(args, *, session: Session = NEW_SESSION) -> None:
     """Display dags with import errors on the command line."""
-    data = []
+    data: list[dict[str, str]] = []
 
-    if args.local:
+    if args.dag_path:
+        if args.bundle_name:
+            raise SystemExit("--dag-path cannot be used with --bundle-name")
+
+        path = Path(args.dag_path).resolve()
+        if path.is_file():
+            bundle_path = path.parent
+        elif path.is_dir():
+            bundle_path = path
+        else:
+            raise SystemExit(f"Dag path {path} does not exist or is not a file 
or directory.")
+
+        path_dagbag = BundleDagBag(path, bundle_path=bundle_path)

Review Comment:
   An explicitly selected file skipped by Dag discovery now emits a warning on 
`stderr`. The command returns JSON `[]` on `stdout` with exit code `0`. I added 
coverage for safe-mode skips, unsupported files, and directory scans.



##########
airflow-core/src/airflow/cli/commands/dag_command.py:
##########
@@ -672,9 +673,26 @@ def dag_details(args, *, session: Session = NEW_SESSION):
 @provide_session
 def dag_list_import_errors(args, *, session: Session = NEW_SESSION) -> None:
     """Display dags with import errors on the command line."""
-    data = []
+    data: list[dict[str, str]] = []
 
-    if args.local:
+    if args.dag_path:
+        if args.bundle_name:
+            raise SystemExit("--dag-path cannot be used with --bundle-name")
+
+        path = Path(args.dag_path).resolve()
+        if path.is_file():
+            bundle_path = path.parent
+        elif path.is_dir():
+            bundle_path = path
+        else:
+            raise SystemExit(f"Dag path {path} does not exist or is not a file 
or directory.")
+
+        path_dagbag = BundleDagBag(path, bundle_path=bundle_path)
+        data.extend(

Review Comment:
   `--dag-path` error rows now include an empty `bundle_name` alongside 
`filepath` and `error`. Paths are absolute for `--dag-path` and relative to the 
bundle root for named bundles. The tests cover the new field for both file and 
directory selections.



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