diff --git a/airflow/www/views.py b/airflow/www/views.py index c4230c1900bc2..f51fbb9e79c93 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -3013,6 +3013,9 @@ def legacy_graph(self): def graph(self, dag_id: str, session: Session = NEW_SESSION): """Redirect to the replacement - grid + graph. Kept for backwards compatibility.""" dag = get_airflow_app().dag_bag.get_dag(dag_id, session=session) + if not dag: + flash(f'DAG "{dag_id}" seems to be missing from DagBag.', "error") + return redirect(url_for("Airflow.index")) dt_nr_dr_data = get_date_time_num_runs_dag_runs_form_data(request, session, dag) dttm = dt_nr_dr_data["dttm"] dag_run = dag.get_dagrun(execution_date=dttm)