sjyangkevin commented on issue #52574:
URL: https://github.com/apache/airflow/issues/52574#issuecomment-3130449988

   After observing the metadata store, I think the issue is because the 
following:
   
   First, the asset itself doesn't contain any `extra`.
   <img width="1155" height="397" alt="Image" 
src="https://github.com/user-attachments/assets/ed5520a9-a573-4d4f-8022-1f3fcfd70a4d";
 />
   
   When you do `outlet_events[asset].extra = {"name1": "value1", "nested_obj": 
{"name2": "value2"}}`, the `extra` is attached to the asset event.
   
   <img width="1155" height="397" alt="Image" 
src="https://github.com/user-attachments/assets/55ff1005-771b-43a8-abb7-6854879c81b3";
 />
   
   The `extra` is propagated into the **consumer** DAG, and can be accessed 
through either `consumed_asset_events` or `triggering_asset_events`.
   
   <img width="864" height="340" alt="Image" 
src="https://github.com/user-attachments/assets/b4de3aaf-276d-467e-a4b8-63836661c925";
 />
     
   Looking at the code below that populate the context for task instance, it 
looks like both `InletEventsAccessors` and `OutletEventAccessors` are querying 
for the Asset model. However, the `extra` is attached to the asset event 
instead of the asset. So, it is why when accessing the outlet_events in the 
listener, the `extra` is empty.
   
   
https://github.com/apache/airflow/blob/0cd0ff0872cea4dffa088a88b54001d157de6e8e/airflow-core/src/airflow/models/taskinstance.py#L1922-L1925
   
   
https://github.com/apache/airflow/blob/0cd0ff0872cea4dffa088a88b54001d157de6e8e/airflow-core/src/airflow/utils/context.py#L126-L148
   
   
https://github.com/apache/airflow/blob/0cd0ff0872cea4dffa088a88b54001d157de6e8e/task-sdk/src/airflow/sdk/execution_time/context.py#L503-L512
   
   It would be great if @uranusjr and @Lee-W could kindly have a look at this, 
and correct me if anything is wrong here. I am not sure if it is by-design, or 
we should adjust these two accessors to query for the asset event associated 
with this asset trigger. Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to