Fix Dag serialization crash for Task SDK EventsTimetable - #69401
Conversation
|
Confirmed the root cause: the SDK serialize_timetable for EventsTimetable in serialization/encoders.py emits only event_dates/restrict_to_events/description and omits _summary (which #51203 made a field the core deserialize read unconditionally), so a DAG using |
A Dag scheduled with the Task SDK EventsTimetable failed to serialize because the SDK timetable serializer omits the _summary key, while the core EventsTimetable.deserialize required it unconditionally and raised KeyError. Fall back to the summary computed by __init__ when the key is absent, so Dags using the SDK timetable serialize and schedule again while existing serialized data keeps its stored summary. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Any Dag scheduled with the Task SDK
EventsTimetable(
from airflow.sdk import EventsTimetable) currently fails to serialize withSerializationError: Failed to serialize DAG '...': '_summary', so the Dagcannot be parsed or scheduled.
The SDK timetable serializer in
airflow-core/src/airflow/serialization/encoders.pyemits only
{event_dates, restrict_to_events, description}and omits the_summarykey, but the coreEventsTimetable.deserializeinairflow-core/src/airflow/timetables/events.pyreaddata["_summary"]unconditionally and raised
KeyErrorwhen it was absent. The two areasymmetric:
_summarybecame a required serialized field in #51203, and theSDK serializer that omits it was added in #58669.
This makes
deserializeretain the summary already computed byEventsTimetable.__init__when_summaryis absent. Dags using the SDKtimetable serialize and schedule again, while existing serialized data that
still carries
_summarykeeps its stored value.A parametrized regression test round-trips a Dag scheduled with the SDK
EventsTimetablethroughDagSerializationwith and without a descriptionand asserts the summary is preserved.
Was generative AI tooling used to co-author this PR?