Skip to content

DAG Bundles: Duplicate dag_id across bundles causes DagModel overwrite and split-brain workload execution #76551

Open

Description

@meel-ayush

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_version

And 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

  1. Configure two versioned bundles: bundle_alpha (commit 1111111) and bundle_beta (commit 2222222).
  2. Add a DAG with dag_id="shared_pipeline" to both bundles.
  3. Parse bundle_alpha and schedule a DagRun. A TaskInstance is queued with bundle_version="1111111".
  4. Parse bundle_beta. DagModel.bundle_name is updated to bundle_beta.
  5. The scheduler constructs the workload: bundle_info.name = "bundle_beta" and bundle_info.version = "1111111".
  6. The worker tries to initialize bundle_beta with commit 1111111 and crashes with AirflowException.

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

Activity

  1. added
    kind:bug
    needs-triage
    on Nov 5, 2026
  2. amoghrajesh commented on Nov 6, 2026

    @amoghrajesh
    Contributor

    I think this has been the behaviour since 3.0 because dag_id is 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.

  3. meel-ayush commented on Nov 6, 2026

    @meel-ayush
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions