From f2fc8e8f8eb860afda2646eb8d3b033ff5d07ec7 Mon Sep 17 00:00:00 2001 From: Daniel Standish <15932138+dstandish@users.noreply.github.com> Date: Sat, 30 Oct 2021 20:40:24 -0700 Subject: [PATCH 1/2] Clarify dag-not-found error message In this context, what's really happening is, we can't find the dag. From a user perspective, when you encounter this error, 'could not find the dag' is a more intuitive representation of the problem than 'could not find the dag_id'. --- airflow/utils/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airflow/utils/cli.py b/airflow/utils/cli.py index 6284605d08622..7e1cbf3f0f596 100644 --- a/airflow/utils/cli.py +++ b/airflow/utils/cli.py @@ -177,7 +177,7 @@ def get_dag_by_file_location(dag_id: str): dag_model = DagModel.get_current(dag_id) if dag_model is None: raise AirflowException( - f'dag_id could not be found: {dag_id}. Either the dag did not exist or it failed to parse.' + f"Dag '{dag_id}' could not be found; either it does not exist or it failed to parse." ) dagbag = DagBag(dag_folder=dag_model.fileloc) return dagbag.dags[dag_id] @@ -190,7 +190,7 @@ def get_dag(subdir: Optional[str], dag_id: str) -> "DAG": dagbag = DagBag(process_subdir(subdir)) if dag_id not in dagbag.dags: raise AirflowException( - f'dag_id could not be found: {dag_id}. Either the dag did not exist or it failed to parse.' + f"Dag '{dag_id}' could not be found; either it does not exist or it failed to parse." ) return dagbag.dags[dag_id] From f6cb25ef31d825bcd5eda8a3fec554f07c7ea8fa Mon Sep 17 00:00:00 2001 From: Daniel Standish <15932138+dstandish@users.noreply.github.com> Date: Sun, 31 Oct 2021 10:33:31 -0700 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil BreguĊ‚a --- airflow/utils/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airflow/utils/cli.py b/airflow/utils/cli.py index 7e1cbf3f0f596..9851d3ed50ffc 100644 --- a/airflow/utils/cli.py +++ b/airflow/utils/cli.py @@ -177,7 +177,7 @@ def get_dag_by_file_location(dag_id: str): dag_model = DagModel.get_current(dag_id) if dag_model is None: raise AirflowException( - f"Dag '{dag_id}' could not be found; either it does not exist or it failed to parse." + f"Dag {dag_id!r} could not be found; either it does not exist or it failed to parse." ) dagbag = DagBag(dag_folder=dag_model.fileloc) return dagbag.dags[dag_id] @@ -190,7 +190,7 @@ def get_dag(subdir: Optional[str], dag_id: str) -> "DAG": dagbag = DagBag(process_subdir(subdir)) if dag_id not in dagbag.dags: raise AirflowException( - f"Dag '{dag_id}' could not be found; either it does not exist or it failed to parse." + f"Dag {dag_id!r} could not be found; either it does not exist or it failed to parse." ) return dagbag.dags[dag_id]