Repository navigation
Conversation
kir-rin
force-pushed
the
fix-dag-discovery-safe-mode-config
branch
from
May 23, 2026 04:40
93aeac8 to
55e167f
Compare
Contributor
Author
|
Closing this PR. After further investigation:
Based on these reasons, the behavior of evaluating default arguments at module load time is standard Python behavior and consistent with Airflow's design philosophy. This is not a code bug. |
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: #66104
Problem
When
DAG_DISCOVERY_SAFE_MODEis set toFalsein the config, Python fileswithout "airflow" or "dag" keywords are still being skipped during DAG discovery.
This happens because the default argument
safe_mode=conf.getboolean(...)inlist_py_file_paths()is evaluated at module load time, not at call time.Once evaluated, the value is fixed and subsequent config changes are ignored.
Solution
Use the existing
NOTSETsentinel pattern (already used inDagBag) to deferconfig reading to runtime:
This ensures the config value is read at call time, allowing runtime config
changes to take effect.
Testing
Added a test that would fail without this fix, verifying that:
safe_mode=Truesafe_mode=FalseWas generative AI tooling used to co-author this PR?
Generated-by: GLM-5 following the guidelines