From 5605d1063be9532a2f9861283998c39bd06e4ce8 Mon Sep 17 00:00:00 2001 From: Sumit Maheshwari Date: Fri, 9 Oct 2020 13:29:41 +0530 Subject: [PATCH] Fix DagBag bug when a dag has invalid schedule_interval (#11344) --- airflow/models/dagbag.py | 2 +- tests/models/test_dagbag.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/airflow/models/dagbag.py b/airflow/models/dagbag.py index 80ae522e0b944..ed709f916d948 100644 --- a/airflow/models/dagbag.py +++ b/airflow/models/dagbag.py @@ -352,9 +352,9 @@ def _process_modules(self, filepath, mods, file_last_changed_on_disk): dag.fileloc = filepath try: dag.is_subdag = False - self.bag_dag(dag=dag, root_dag=dag) if isinstance(dag.normalized_schedule_interval, str): croniter(dag.normalized_schedule_interval) + self.bag_dag(dag=dag, root_dag=dag) found_dags.append(dag) found_dags += dag.subdags except (CroniterBadCronError, diff --git a/tests/models/test_dagbag.py b/tests/models/test_dagbag.py index c2fe0457feafc..9cf0c006fcca0 100644 --- a/tests/models/test_dagbag.py +++ b/tests/models/test_dagbag.py @@ -174,6 +174,7 @@ def test_process_file_cron_validity_check(self): for file in invalid_dag_files: dagbag.process_file(os.path.join(TEST_DAGS_FOLDER, file)) self.assertEqual(len(dagbag.import_errors), len(invalid_dag_files)) + self.assertEqual(len(dagbag.dags), 0) @patch.object(DagModel, 'get_current') def test_get_dag_without_refresh(self, mock_dagmodel):