Copilot commented on code in PR #46849:
URL: https://github.com/apache/airflow/pull/46849#discussion_r1992798799
##########
airflow/cli/commands/remote_commands/dag_command.py:
##########
@@ -576,6 +609,29 @@ def _render_dagrun(dr: DagRun) -> dict[str, str]:
AirflowConsole().print_as(data=dag_runs, output=args.output,
mapper=_render_dagrun)
+def _parse_and_get_dag(dag_id: str) -> DAG | None:
+ """Given a dag_id, determine the bundle and relative fileloc from the db,
then parse and return the DAG."""
+ db_dag = get_dag(subdir=None, dag_id=dag_id, from_db=True)
Review Comment:
The _parse_and_get_dag function does not check whether get_dag returns None
before calling db_dag.get_bundle_name(), which may lead to an AttributeError.
Consider adding a check for None and handling that case explicitly.
```suggestion
db_dag = get_dag(subdir=None, dag_id=dag_id, from_db=True)
if db_dag is None:
raise AirflowException(f"DAG {dag_id!r} not found in the database.")
```
--
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]