Repository navigation
Description
Under which category would you file this issue?
Airflow Core
Apache Airflow version
3.4.0rc3 (and main)
What happened and how to reproduce it?
Description
In Airflow 3, dag.dag_id is the primary key on DagModel across all configured DAG bundles (bundle_name is an attribute, not part of the primary key). When two separate bundles (e.g. two git repositories) declare a DAG with the same dag_id, parsing the second bundle unconditionally overwrites DagModel.bundle_name and DagModel.relative_fileloc.
When the scheduler queues a task instance originally scheduled under the first bundle, ExecuteTask.make(ti) builds a split-brain workload combining the second bundle's name and file path with the first bundle's git commit SHA. When the worker attempts to initialize the bundle repository, execution crashes:
AirflowException: Version '1111111' not found in the repository for bundle 'bundle_beta'. Available versions: ['2222222']
In multi-team setups, this also reassigns task ownership to the second team, causing the Execution API to reject the original team's worker with HTTP 403 Forbidden.
Affected Code
In airflow-core/src/airflow/dag_processing/collection.py:830-831:
dm.bundle_name = self.bundle_name
dm.bundle_version = self.bundle_versionAnd in airflow-core/src/airflow/executors/workloads/task.py:122-124:
bundle_info = BundleInfo(
name=ti.dag_model.bundle_name, # Reads bundle_beta from overwritten DagModel
version=ti.dag_run.bundle_version, # Reads bundle_alpha's git commit SHA from DagRun
version_data=_resolve_version_data(ti.dag_run.created_dag_version, ti.dag_run.bundle_version),
)Steps to Reproduce
- Configure two versioned bundles:
bundle_alpha(commit1111111) andbundle_beta(commit2222222). - Add a DAG with
dag_id="shared_pipeline"to both bundles. - Parse
bundle_alphaand schedule aDagRun. ATaskInstanceis queued withbundle_version="1111111". - Parse
bundle_beta.DagModel.bundle_nameis updated tobundle_beta. - The scheduler constructs the workload:
bundle_info.name = "bundle_beta"andbundle_info.version = "1111111". - The worker tries to initialize
bundle_betawith commit1111111and crashes withAirflowException.
Expected Behavior
A duplicate dag_id in a secondary bundle should not overwrite the bundle_name or file location of an already registered DAG from another bundle. The conflicting definition should be rejected with an import error or ignored until resolved.
Proposed Fix
In airflow-core/src/airflow/dag_processing/collection.py, check if existing.bundle_name != incoming_bundle before updating DagModel. If a duplicate DAG ID is detected from a different bundle, retain the existing bundle association on DagModel and record a ParseImportError for the secondary file.
I have verified this behavior with a local reproduction script and am working on a PR with regression tests to fix this.
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
amoghrajesh commentedon Nov 6, 2026
I think this has been the behaviour since 3.0 because
dag_idis unique across bundles. Two bundles defining the same Dag is a misconfiguration, but maybe we should detect it and surface an error instead of silently switching between bundles if thats whats happening.meel-ayush commentedon Nov 6, 2026
Exactly, that was the main issue it was silently overwriting the primary bundle's DagModel metadata, which led to mismatched version SHAs at execution time.
#76556 catches it during collection and logs a parse import error on the second bundle rather than silently switching.