Skip to content

Reject serde payloads newer than the uuid and datetime serializers - #72637

Closed
aniketwaghh wants to merge 2 commits into
apache:mainfrom
aniketwaghh:fix-serde-version-guard
Closed

aniketwaghh wants to merge 2 commits into
apache:mainfrom
aniketwaghh:fix-serde-version-guard

Conversation

@aniketwaghh

Copy link
Copy Markdown

closes: #72636

Registered serde serializers own their version check. serde/__init__.py dispatches straight to _deserializers[classname].deserialize(cls, version, ...), and the version > class_version guard further down applies only to the attr/dataclass fallback, which a registered serializer never reaches.

Nine of the eleven serializers with a deserialize() raise when the payload version exceeds their own. uuid.py and datetime.py did not, so a value written by a newer Airflow was read under the old assumptions rather than refused. (kubernetes.py has no deserialize, so eleven is the relevant set.)

On main, deserializing a version=99 payload:

bignum   (guarded)     rejected  (serialized 99 of decimal.Decimal > 1)
uuid     (no guard)    ACCEPTED -> UUID('12345678-1234-5678-1234-567812345678')
datetime (no guard)    ACCEPTED -> datetime.timedelta(seconds=60)

After, both are rejected with the message their siblings already use.

Nothing changes for any payload that exists today: both serializers are at the version they ship with, so nothing in the wild carries a higher one. It matters the next time either format changes, when whoever bumps __version__ would reasonably assume the guard was already there — and its absence would not be visible in that diff.

The datetime serializer still reads its version-1 payloads, legacy short-code timezones included; only versions above its current 2 are rejected.

Two tests. test_deserialize_rejects_a_newer_version covers uuid, timedelta and datetime and fails on main for all three. test_deserialize_still_accepts_the_current_and_legacy_versions pins the versions that are in use, including the v1 legacy timezone path; it passes either way, so it is a regression guard rather than a bug test.

task-sdk suite on this branch and on main at 123b1be658, same machine: 17 failed / 2786 passed here against 17 failed / 2782 passed there, the four extra passes being the parametrised cases above. The seventeen failures are the same seventeen on both sides — deltalake serializers, provider-manager runtime, and some param/supervisor/task-runner cases, all from optional dependencies missing locally. ruff 0.16.4, the version .pre-commit-config.yaml pins, is clean on the three changed files.


^ Add meaningful description above

Registered serde serializers are responsible for their own version check:
serde dispatches straight to _deserializers[classname].deserialize, and the
version guard in serde/__init__.py covers only the attr/dataclass fallback,
which a registered serializer never reaches.

Nine of the eleven serializers with a deserialize() raise when the payload
version exceeds their own. uuid and datetime did not, so a value written by a
newer Airflow was read under the old assumptions instead of being refused.

No payload in the wild carries a higher version today, since both serializers
are at the version they ship with. This matters the next time either format
changes, when the guard would reasonably be assumed to already exist.

The datetime serializer keeps reading its version-1 payloads, legacy short-code
timezones included; only versions above its current 2 are rejected.
@boring-cyborg

boring-cyborg Bot commented Sep 7, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

The rejection test called the serializer's deserialize() directly, which
skipped the dispatch its own docstring describes, and carried an unused
import silenced with noqa to paper over that. Encode the payload and go
through serde.deserialize() instead, matching test_deserialize_datetime_v1.

Drop test_deserialize_still_accepts_the_current_and_legacy_versions. The
existing tests already cover in-use versions and now dispatch through the new
check: making the guard reject version >= 1 fails 17 of them, including
test_deserialize_datetime_v1 and test_datetime.
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Oct 28, 2026
@github-actions github-actions Bot closed this Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:task-sdk stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serde: uuid and datetime serializers accept payloads from a newer version

2 participants