Skip to content

Expose asset event id and source watcher to asset listeners - #76750

Open
kacpermuda wants to merge 1 commit into
apache:mainfrom
kacpermuda:claude/listener-asset-event-watcher-info-a43680
Open

kacpermuda wants to merge 1 commit into
apache:mainfrom
kacpermuda:claude/listener-asset-event-watcher-info-a43680

Conversation

@kacpermuda

@kacpermuda kacpermuda commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Adds fields to the listener AssetEvent passed to on_asset_event_emitted:

  • id, timestamp, asset_id: from the stored asset event. Core always sets them.
  • source_watcher_name, source_trigger_classpath (optional, default None): the asset watcher whose trigger fired, and the trigger class. Set only for triggerer events.

Consumers such as OpenLineage need these to identify and describe watcher-driven events.

Triggerer safety: no new queries (watchers are already eager-loaded) and no decryption. Trigger kwargs are left out because they may hold secrets.

Related followup in OL listener: #76773


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

🤖 Generated with Claude Code

class AssetEvent:
"""Asset event representation for asset listener hooks."""

id: int

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.

id, timestamp and asset_id are required and sit before asset, so any code that constructs listeners.types.AssetEvent itself (third-party listener tests, mocks) now gets a TypeError or mis-assigned positional args. #67285 added partition_date with a default, last in the list. Could these get defaults and move to the end, or is the intent that only core builds this type.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good question. The intent is that only core builds this type: it’s constructed in exactly one place (AssetManager.register_asset_change), and listeners only receive instances through the on_asset_event_emitted hookspec. I grepped the repo, including providers and task-sdk, for other uses of airflow.listeners.types and found none. Core already passes every field as a keyword argument, so the new required fields at the front can’t mis-assign anything.

I left them at the start because moving them behind partition_date would need defaults, which makes no sense for a persisted event’s id, timestamp and asset_id. Alternatively they’d need kw_only=True on those fields, which adds complexity for a type nobody outside core constructs. Happy to do that if you’d rather be strict about it, but I think the current ordering is fine.

@kacpermuda
kacpermuda force-pushed the claude/listener-asset-event-watcher-info-a43680 branch from a9f0dc9 to b61c91f Compare November 20, 2026 11:41
@kacpermuda

Copy link
Copy Markdown
Collaborator Author

Can we backport this to 3.4.1 ?

@Lee-W

Lee-W commented Nov 20, 2026

Copy link
Copy Markdown
Member

I don't think this should target 3.4.1. @vatsrahul1001 WDYT?

This branch has not been deployed

No deployments
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