Skip to content

Warn when two Dag bundles read the same source - #77313

Closed
bnspopi wants to merge 1 commit into
apache:mainfrom
bnspopi:fix/warn-bundles-with-same-source
Closed

bnspopi wants to merge 1 commit into
apache:mainfrom
bnspopi:fix/warn-bundles-with-same-source

Conversation

@bnspopi

@bnspopi bnspopi commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

DagBundlesManager.parse_config keys bundles by name and never compares where they read their files from. If the same Git repository, branch and subdir is configured twice, once with an SSH URL and once with an HTTPS URL, Airflow accepts both as independent bundles. The Dag processor then clones and parses everything twice, every import error is reported twice, and each Dag keeps moving from one bundle to the other. That is what #77241 reports.

This adds the detection described in the issue, as a warning only:

  • BaseDagBundle.source_key(**kwargs) is a new classmethod that says where a bundle with those kwargs reads from. It returns None by default, which means "not known", so existing and third-party bundles are unaffected.
  • LocalDagBundle returns its resolved directory.
  • GitDagBundle returns the repository as host/path together with the tracking ref and the subdir. The user, port and .git suffix are dropped and the host is lower-cased, so [email protected]:org/repo.git, ssh://[email protected]:22/org/repo.git and https://[email protected]/org/repo give the same key. When repo_url is not in the kwargs (it comes from the connection) or is a local path, the key is None and the bundle is not compared.
  • DagBundlesManager.parse_config logs a warning naming the bundles that share a key.
  • dag-bundles.rst and the duplicate dag id FAQ entry now say that two bundles must not read the same source.

Left out on purpose:

  • The [dag_processor] reject_duplicate_bundle_sources flag that would turn the warning into an error. It is a new config option and a separate decision.
  • Nested subdirs of one repository (subdir="" and subdir="dags"). The issue notes this can be intentional.
  • The warning is logged every time a DagBundlesManager parses the config, so it appears in the log of each component that loads the bundle configuration.

@basantjamwal proposed this same plan in the issue. I am happy to close this in favour of their PR if they already have one in progress.

Tests, run on Linux with SQLite:

  • test_dag_bundle_manager.py, test_local.py, test_base.py: 107 passed (5 new cases).
  • providers/git/tests/unit/git/bundles/test_git.py: 142 passed (11 new cases).
  • Without the source changes, 14 of the new cases fail.

related: #77241


Was generative AI tooling used to co-author this PR?
  • Yes (Claude Code)

Generated-by: Claude Code following the guidelines

🤖 Generated with Claude Code

DagBundlesManager keys bundles by name and never compares where they
read their files from. The same Git repository, branch and subdir
configured twice, once with an SSH URL and once with an HTTPS URL, was
accepted as two bundles: every file was parsed twice, import errors were
reported twice, and each Dag kept moving from one bundle to the other.

Bundles can now say where they read from through a source_key()
classmethod on BaseDagBundle, which returns None by default. The manager
logs a warning when two configured bundles return the same key.

LocalDagBundle returns its resolved directory. GitDagBundle returns the
repository as host/path (without user, port or .git, so SSH and HTTPS
URLs compare equal) together with the tracking ref and the subdir. When
the repository URL comes from the connection, the key is not known at
this point and the bundle is not compared.

The docs now say that two bundles must not read the same source.

related: apache#77241

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@basantjamwal

Copy link
Copy Markdown
Contributor

Hi @bnspopi, thanks for the heads-up, and for tagging me.

I'd reproduced this and posted the root cause and plan on #77241, and I'm already working on my own PR, which I'll raise shortly. Since you mentioned you'd be happy to close yours if mine is in progress, I'd really appreciate that. Thanks for understanding!

@bnspopi

bnspopi commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @basantjamwal, and no problem. I will leave this as a draft for now so the fix is not lost, and close it as soon as your PR is up. If anything here is useful for yours (the URL normalisation or the test cases), feel free to take it.

@basantjamwal

Copy link
Copy Markdown
Contributor

Hi @bnspopi, my PR is up: #77375. Thanks for the heads-up and for offering the test cases, I've credited them in the description.

@bnspopi

bnspopi commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @basantjamwal. Closing this in favour of #77375 as promised, and thanks for the credit.

@bnspopi bnspopi closed this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants