You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ms...@apache.org on 2020/10/09 08:00:23 UTC

[airflow] branch master updated: Fix DagBag bug when a dag has invalid schedule_interval (#11344)

This is an automated email from the ASF dual-hosted git repository.

msumit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 5605d10  Fix DagBag bug when a dag has invalid schedule_interval (#11344)
5605d10 is described below

commit 5605d1063be9532a2f9861283998c39bd06e4ce8
Author: Sumit Maheshwari <sm...@twitter.com>
AuthorDate: Fri Oct 9 13:29:41 2020 +0530

    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 80ae522..ed709f9 100644
--- a/airflow/models/dagbag.py
+++ b/airflow/models/dagbag.py
@@ -352,9 +352,9 @@ class DagBag(BaseDagBag, LoggingMixin):
                     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 c2fe045..9cf0c00 100644
--- a/tests/models/test_dagbag.py
+++ b/tests/models/test_dagbag.py
@@ -174,6 +174,7 @@ class TestDagBag(unittest.TestCase):
         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):