Skip to content

Fix wrong watcher name for assets sharing an identical trigger - #76982

Merged
Lee-W merged 1 commit into
apache:mainfrom
kacpermuda:claude/fix-shared-trigger-watcher-names-77f321
Nov 20, 2026
Merged

Lee-W merged 1 commit into
apache:mainfrom
kacpermuda:claude/fix-shared-trigger-watcher-names-77f321

Conversation

@kacpermuda

@kacpermuda kacpermuda commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

When watchers on different assets used an identical trigger (same class and kwargs), add_asset_trigger_references stored the watcher name of the last processed asset for all of them. Watcher names are now tracked per asset.

orders = Asset("orders", watchers=[AssetWatcher(name="orders_watcher", trigger=FileDeleteTrigger(filepath="/x"))])
customers = Asset("customers", watchers=[AssetWatcher(name="customers_watcher", trigger=FileDeleteTrigger(filepath="/x"))])

Both watchers correctly share one Trigger row, but the trigger info (including watcher_name) was collected into one dict for all assets, keyed only by trigger hash. The second asset overwrote the first asset's entry, so orders got a watcher named customers_watcher. The trigger still fired for both assets, so only the stored name was wrong.

Watcher names were also only written when a reference was created, so a wrong name already stored by this bug, or a watcher renamed in the Dag file with the same trigger, stayed wrong until the Dag was paused and unpaused. Existing watcher names are now updated on every sync.

related: #76750 (exposes the watcher name to listeners)
related: #76773 (its OpenLineage e2e test with two assets sharing a trigger got the wrong watcherName)


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

Generated-by: Claude Code (Opus 5.5) following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

🤖 Generated with Claude Code

@bingqin2 bingqin2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on main at da7dab3 on macOS (SQLite). collection.py, models/asset.py and test_collection.py haven't changed between that commit and 7dfc579.

I synced one Dag scheduled on two assets whose watchers use an identical FileDeleteTrigger:

  • On main both asset_watcher rows are named b_watcher. With this change they are a_watcher and b_watcher, and there is still one Trigger row.
  • The new test fails on main and passes with this change. test_collection.py passes (99 passed, 2 skipped), and ruff and mypy pass on the changed files.

Not blocking: the name is written only when the reference is created, so two cases keep the old name on the next sync, on main and with this change:

Case Stored name after the next sync
Rows that main already stored as b_watcher for both assets still b_watcher for both
A watcher renamed in the Dag file, with the same trigger still the old name

Pausing and unpausing the Dag recreates the references with the right names. I also tried updating the name of the references that already exist, before the "no diff" shortcut. Both cases then store the right name, and test_collection.py still passes. Since #76750 exposes this name to listeners, it may be worth a follow-up.

The change I tried
            # Keep the names of references that already exist in step with the Dag definition.
            for watcher in asset_model.watchers:
                if watcher.trigger is None:
                    continue
                current_name = watcher_names[name_uri].get(
                    BaseEventTrigger.hash(watcher.trigger.classpath, watcher.trigger.kwargs)
                )
                if current_name is not None and watcher.name != current_name:
                    watcher.name = current_name

@kacpermuda
kacpermuda force-pushed the claude/fix-shared-trigger-watcher-names-77f321 branch from 48b0bfc to 194c12b Compare November 13, 2026 10:06
@kacpermuda

Copy link
Copy Markdown
Collaborator Author

Thanks, addressed this in the last commit

@Lee-W Lee-W left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the Co-Authored-By: Claude ... trailer in each commit

@kacpermuda
kacpermuda force-pushed the claude/fix-shared-trigger-watcher-names-77f321 branch from 194c12b to a7764bb Compare November 20, 2026 11:32
@kacpermuda

Copy link
Copy Markdown
Collaborator Author

Done, good to merge, thanks !

@kacpermuda

Copy link
Copy Markdown
Collaborator Author

Can we backport this to 3.4.1 ?

@Lee-W Lee-W added the backport-to-v3-4-test Backport to v3-4-test label Nov 20, 2026
@Lee-W Lee-W added this to the Airflow 3.4.1 milestone Nov 20, 2026
@Lee-W
Lee-W enabled auto-merge (squash) November 20, 2026 13:26
@Lee-W
Lee-W merged commit 60d6099 into apache:main Nov 20, 2026
70 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-4-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-4-test PR Link

Lee-W pushed a commit that referenced this pull request Nov 24, 2026
…igger (#76982)

(cherry picked from commit 60d6099)

Co-authored-by: Kacper Muda <[email protected]>
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.

3 participants