Repository navigation
Description
Under which category would you file this issue?
Airflow Core
Apache Airflow version
3.0.3
What happened and how to reproduce it?
Issue Description
Airflow does not parse all files even though dag_discovery_safe_mode = false.
We created an internal wrapper for Airflow, so we import definitions from our wrapper and not directly from Airflow. This results in whole projects that define Airflow DAGs and Tasks that don't have the words "airflow" or "dag" in them at all.
In order for Airflow to still parse the wrapped DAGs, we need it to parse all files, disregarding the existence of "airflow" and "dag" being present.
In order to achieve this we set dag_discovery_safe_mode = false, but the DAGs still don't appear.
They appear after running airflow dags reserialize, but disappear after a few minutes each time.
They obviously appear permanently if we add "airflow" and "dag" to the files, but we're trying to avoid this solution.
Steps to reproduce
-> Create an Airflow DAG wrapper with names not containing "airflow" or "dag"
-> Turn dag_discovery_safe_mode to False
-> Wrapped DAGs don't appear in UI
-> After running airflow dags reserialize they appear, but disappear shortly after
-> Adding "# DAG airflow" or "from airflow.sdk import dag" makes them appear permanently
simple DAG wrapping
from functools import wraps
from airflow import DAG
from airflow.sdk import dag
@wraps(dag)
def flow(*dag_args, **dag_kwargs):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
with DAG(dag_id=func.__name__, *dag_args, **dag_kwargs) as dag:
func(*args, **kwargs)
return wrapper
return decoratorWhat you think should happen instead?
After setting dag_discovery_safe_mode = false wrapped DAGs will permanently appear in UI and be parsed normally.
Operating System
Run on OpenShift
Deployment
Official Apache Airflow Helm Chart
Apache Airflow Provider(s)
No response
Versions of Apache Airflow Providers
No response
Official Helm Chart version
1.18.0
Kubernetes Version
OpenShift 4.16
Helm Chart configuration
No response
Docker Image customizations
No response
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
boring-cyborg commentedon Apr 29, 2026
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
saidiraja commentedon Apr 29, 2026
Reproduction attempt (Airflow 3.2.0)
Environment
What I tested
I created a DAG file (hidden_flow.py) that does not explicitly contain typical keywords like "airflow" or "dag".
Then I disabled safe mode:
export AIRFLOW__CORE__DAG_DISCOVERY_SAFE_MODE=False
and verified:
airflow config get-value core dag_discovery_safe_mode
False
Observations
The DAG was detected when loading via DagBag:
HAS SAFE_MODE_TEST_66104: True
However, it was not listed initially using:
airflow dags list
After starting Airflow using:
airflow standalone
the DAG appeared in the list, could be triggered, and runs were created successfully.
Result
I was not able to fully reproduce the exact issue described.
DAG parsing works correctly when safe mode is disabled, but DAG visibility seems to depend on the scheduler/services being running.
Evidence
Screenshots attached showing:
dayonet commentedon Apr 30, 2026
Thank you for the quick reply. I ran the commands and I found that they really do appear when running
airflow dags listand can be triggered viaairflow dags trigger <dag_id>, which is great!Still, they don't appear in the Airflow UI without running
airflow dags reserializeevery few minutes.We give our Airflow to users in our company so it's important they can see them in the UI and trigger from there as well.
Is there a way to make them appear in the UI permanently?
saidiraja commentedon Apr 30, 2026
Thanks for sharing this , I was able to reproduce the same behavior on my side.
With
dag_discovery_safe_mode=False, the DAG is:airflow dags listHowever, I also observed that it does not appear in the UI unless
airflow dags reserializeis run manually.From what I understand, this may be because DAG discovery (used by CLI) and DAG serialization (used by the UI) are handled separately. The UI relies on the scheduler to serialize DAGs into the metadata DB, so if that step is not triggered automatically, the DAG won’t appear there.
So it seems the issue might not only be about file scanning, but also how DAGs are picked up for serialization when safe mode is disabled.
Curious to hear if others have seen similar behavior or have more insights on this.
dayonet commentedon May 1, 2026
Thank you for the quick and helpful reply.
Since this problem is currently a showstopper for me, I'd like to know if fixing it is on your roadmap (at least in terms of a workaround).
I'm not sure I'm in a position to submit a PR, but I'd like to understand my options.
Happy to help test or provide more details if that’s useful.
dayonet commentedon May 20, 2026
Hi,
Is this supposed to be solved in future versions?
dayonet commentedon May 24, 2026
From what I understand from the PR, the conclusion is that the bug's behavior is as expected due to Airflow's evaluation of default arguments at module load time.
Although I understand that this is the default behavior, I'd appreciate it if a workaround or more robust solution could be provided, since it is causing a concrete bug that's a big issue in our organization.
kir-rin commentedon May 25, 2026
I'm the author of #67325. I'm leaving this comment to explain why I closed the PR.
Since config changes require a restart, I don't think the default argument evaluation at module load time is a bug.
I tried to reproduce the issue to identify the actual root cause, but couldn't — the DAG files appeared in the UI correctly in my tests.
I tested both
airflow standaloneand separatescheduler+api-server+processorsetups.Example files I used (same wrapper pattern from the issue description):
dags/wrapper/flow.py— the wrapper decoratordags/test.py— uses the wrapper, also no keywordsThe DAG was discovered and visible in the UI after setting
DAG_DISCOVERY_SAFE_MODE=Falseand restarting.dayonet commentedon May 31, 2026
Did the DAG stay in the UI after the next DAG serialization? In my experience it shows up in the UI for a few minutes, and then disappears. It returns upon running
airflow dags reserialize, and disappears again on the next automatic reserialization, just like @saidiraja experienced.Keep ZIP-archived Dags active when dag_discovery_safe_mode is False
Keep ZIP-archived Dags active when dag_discovery_safe_mode is False (a…
[v3-3-test] Keep ZIP-archived Dags active when dag_discovery_safe_mod…
[v3-3-test] Keep ZIP-archived Dags active when dag_discovery_safe_mod…
[v3-3-test] Keep ZIP-archived Dags active when dag_discovery_safe_mod…