Repository navigation
Expose asset event id and source watcher to asset listeners - #76750
kacpermuda wants to merge 1 commit into
Conversation
10952ee to
2b76e98
Compare
| class AssetEvent: | ||
| """Asset event representation for asset listener hooks.""" | ||
|
|
||
| id: int |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
a9f0dc9 to
b61c91f
Compare
|
Can we backport this to 3.4.1 ? |
|
I don't think this should target 3.4.1. @vatsrahul1001 WDYT? |
Adds fields to the listener
AssetEventpassed toon_asset_event_emitted:id,timestamp,asset_id: from the stored asset event. Core always sets them.source_watcher_name,source_trigger_classpath(optional, defaultNone): 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?
Generated-by: Claude Code (Opus 5.5) following the guidelines
🤖 Generated with Claude Code