Skip to content

Fix ARG_NOT_SET deserialization for _date fields in OperatorSerialization#66564

Open
hwang-cadent wants to merge 1 commit intoapache:mainfrom
hwang-cadent:fix-arg-not-set-deserialization-date-fields
Open

Fix ARG_NOT_SET deserialization for _date fields in OperatorSerialization#66564
hwang-cadent wants to merge 1 commit intoapache:mainfrom
hwang-cadent:fix-arg-not-set-deserialization-date-fields

Conversation

@hwang-cadent
Copy link
Copy Markdown
Contributor

Summary

OperatorSerialization._deserialize_field_value previously routed every *_date field directly to _deserialize_datetime. When an operator stores a date-suffixed field as NOTSET (an ArgNotSet sentinel meaning "use the default at runtime"), the value is encoded as {__type: ARG_NOT_SET}. Passing that encoding to _deserialize_datetime raises because it is not a datetime payload, so deserializing such an operator (for example TriggerDagRunOperator whose logical_date defaults to NOTSET) fails.

This PR short-circuits the ARG_NOT_SET case on date-suffixed fields and restores the NOTSET singleton. None values and real datetimes keep their existing behavior.

Why a separate PR

This was originally bundled inside #56973 (dynamic dag_id resolution in TriggerDagRunOperator links). Per reviewer feedback from @potiuk, splitting it out keeps each concern independently reviewable, bisectable and backportable. #56973 is being rebased to drop the serialization change once this PR lands.

Changes

  • airflow-core/src/airflow/serialization/serialized_objects.py: handle ARG_NOT_SET in _deserialize_field_value for date-suffixed fields.
  • airflow-core/tests/unit/serialization/test_serialized_objects.py: add test_deserialize_field_value_with_arg_not_set_for_date_fields covering logical_date, start_date, end_date.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Testing

``OperatorSerialization._deserialize_field_value`` previously sent every
``*_date`` field to ``_deserialize_datetime`` unconditionally. When an
operator stores a date-suffixed field as ``NOTSET`` (an ``ArgNotSet``
sentinel meaning "use the default at runtime") the value is encoded as
``{__type: ARG_NOT_SET}``. Passing that encoded value to
``_deserialize_datetime`` fails because it is not a datetime payload, so
deserializing such an operator (e.g. ``TriggerDagRunOperator`` whose
``logical_date`` defaults to ``NOTSET``) raised an error.

This change short-circuits ARG_NOT_SET on date fields and restores the
``NOTSET`` singleton, leaving ``None`` and real datetimes unchanged.

Adds a direct unit test in ``test_serialized_objects.py`` covering
``logical_date``, ``start_date`` and ``end_date``.
@hwang-cadent hwang-cadent force-pushed the fix-arg-not-set-deserialization-date-fields branch from e1d1f5a to f2b465e Compare May 9, 2026 13:51
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.

1 participant