Vamsi-klu commented on code in PR #68518:
URL: https://github.com/apache/airflow/pull/68518#discussion_r3746410760


##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -299,6 +299,11 @@ class DagFileProcessorManager(LoggingMixin):
         factory=_config_get_factory("dag_processor", "file_parsing_sort_mode")
     )
 
+    dag_discovery_safe_mode: bool = attrs.field(
+        factory=_config_bool_factory("core", "DAG_DISCOVERY_SAFE_MODE")

Review Comment:
   Applied the suggestion: the config key now uses lowercase 
`dag_discovery_safe_mode`, matching `config.yml` and the sibling factory calls. 
Lookup behavior is unchanged because config keys are case-insensitive.
   
   ---
   Drafted-by: Codex (GPT-5); reviewed by @Vamsi-klu before posting



##########
airflow-core/tests/unit/dag_processing/test_manager.py:
##########
@@ -309,6 +343,54 @@ def 
test_sync_bundles_does_not_deactivate_missing_when_filtered(self):
             manager.sync_bundles()
         
mock_bundles_manager.return_value.sync_bundles_to_db.assert_called_once_with(deactivate_missing=False)
 
+    @pytest.mark.parametrize(
+        "safe_mode",
+        [
+            pytest.param(False, id="safe-mode-off-includes-keywordless"),
+            pytest.param(True, id="safe-mode-on-filters-keywordless"),
+        ],
+    )
+    def test_find_files_in_bundle_respects_dag_discovery_safe_mode(self, 
tmp_path, safe_mode):
+        (tmp_path / "with_keywords.py").write_text("from airflow.sdk import 
DAG\n")
+        (tmp_path / "no_keywords.py").write_text("from mycompany.pipelines 
import flow\n")
+        bundle = MagicMock(spec=BaseDagBundle)
+        bundle.name = "testing"
+        bundle.path = tmp_path
+
+        manager = DagFileProcessorManager(max_runs=1, 
dag_discovery_safe_mode=safe_mode)
+
+        expected = {Path("with_keywords.py")}
+        if not safe_mode:
+            expected.add(Path("no_keywords.py"))
+        assert set(manager._find_files_in_bundle(bundle)) == expected
+
+    @pytest.mark.parametrize(
+        "safe_mode",
+        [
+            pytest.param(False, id="safe-mode-off-includes-keywordless"),
+            pytest.param(True, id="safe-mode-on-filters-keywordless"),
+        ],
+    )
+    def test_get_observed_filelocs_respects_dag_discovery_safe_mode(self, 
tmp_path, safe_mode):

Review Comment:
   Done. Both safe-mode tests now set `[core] dag_discovery_safe_mode` through 
`conf_vars` and construct `DagFileProcessorManager` inside that context, so the 
attrs factory exercises the real configuration path. Focused validation passed 
all four parametrized cases.
   
   ---
   Drafted-by: Codex (GPT-5); reviewed by @Vamsi-klu before posting



-- 
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]

Reply via email to