amoghrajesh commented on code in PR #59711:
URL: https://github.com/apache/airflow/pull/59711#discussion_r2652253021
##########
airflow-core/src/airflow/models/trigger.py:
##########
@@ -417,15 +426,14 @@ def handle_event_submit(event: TriggerEvent, *,
task_instance: TaskInstance, ses
:param task_instance: The task instance to handle the submit event for.
:param session: The session to be used for the database callback sink.
"""
+ from airflow.sdk.serde import serialize
from airflow.utils.state import TaskInstanceState
# Get the next kwargs of the task instance, or an empty dictionary if it
doesn't exist
next_kwargs = task_instance.next_kwargs or {}
- # Add the event's payload into the kwargs for the task
- next_kwargs["event"] = event.payload
-
# Update the next kwargs of the task instance
+ next_kwargs["event"] = serialize(event.payload)
Review Comment:
Thanks for your suggestion, I applied it now a fix as per your suggestions
and now "event" is working fine.
<img width="2560" height="1261" alt="Image"
src="https://github.com/user-attachments/assets/d3ee7610-c8bf-4f0a-b317-7a9f0ffb0968"
/>
Even added some logs to ensure it works fine and it does now!
```python
Raw next_kwargs from DB: {'__var': {'message': 'hello from deferred task',
'numbers': [1, 2, 3, 4, 5], 'timestamp': {'__var': 1767073041.743114, '__type':
'datetime'}, 'numbers_in_tuple': {'__var': [6, 7, 8, 9, 10], '__type':
'tuple'}}, '__type': 'dict'}
Deserialized with BaseSerialization (backward compat)
Deserialized next_kwargs (plain dict): {'message': 'hello from deferred
task', 'numbers': [1, 2, 3, 4, 5], 'timestamp': DateTime(2025, 12, 30, 5, 37,
21, 743114, tzinfo=Timezone('UTC')), 'numbers_in_tuple': (6, 7, 8, 9, 10)}
Event payload to add: 2025-12-30 05:38:21.725567+00:00
After adding event (still plain dict): {'message': 'hello from deferred
task', 'numbers': [1, 2, 3, 4, 5], 'timestamp': DateTime(2025, 12, 30, 5, 37,
21, 743114, tzinfo=Timezone('UTC')), 'numbers_in_tuple': (6, 7, 8, 9, 10),
'event': datetime.datetime(2025, 12, 30, 5, 38, 21, 725567,
tzinfo=datetime.timezone.utc)}
Final serialized next_kwargs: {'message': 'hello from deferred task',
'numbers': [1, 2, 3, 4, 5], 'timestamp': {'__classname__':
'pendulum.datetime.DateTime', '__version__': 2, '__data__': {'timestamp':
1767073041.743114, 'tz': {'__classname__': 'builtins.tuple', '__version__': 1,
'__data__': ['UTC', 'pendulum.tz.timezone.Timezone', 1, True]}}},
'numbers_in_tuple': {'__classname__': 'builtins.tuple', '__version__': 1,
'__data__': [6, 7, 8, 9, 10]}, 'event': {'__classname__': 'datetime.datetime',
'__version__': 2, '__data__': {'timestamp': 1767073101.725567, 'tz':
{'__classname__': 'builtins.tuple', '__version__': 1, '__data__': ['UTC',
'pendulum.tz.timezone.FixedTimezone', 1, True]}}}}
```
--
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]