Skip to content

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

Open

Description

@aniketwaghh

Apache Airflow version

main (3.4.0, 123b1be658)

What happened and how to reproduce it?

Registered serde serializers are expected to reject a payload whose recorded version is newer than the version of the class doing the deserializing — that is what lets an older Airflow refuse an XCom written by a newer one instead of misreading it. Ten of the twelve serializers in task-sdk/src/airflow/sdk/serde/serializers/ do this. uuid.py and datetime.py do not.

The framework does not cover for them. serde/__init__.py dispatches a registered deserializer directly:

if classname in _deserializers:
    return _deserializers[classname].deserialize(cls, version, deserialize(value))

Its own version > class_version check further down applies only to the attr/dataclass fallback, which a registered serializer never reaches. So for these two the check is simply absent.

from decimal import Decimal
import uuid as uuid_mod, datetime as dt
from airflow.sdk.serde.serializers import uuid as s_uuid, datetime as s_dt, bignum

bignum.deserialize(Decimal, 99, "1.5")                       # TypeError, as intended
s_uuid.deserialize(uuid_mod.UUID, 99, "12345678-1234-5678-1234-567812345678")
s_dt.deserialize(dt.timedelta, 99, 60.0)

On main:

declared __version__: uuid=1 datetime=2 bignum=1 numpy=1

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)

kubernetes.py has no deserialize at all, so the remaining eleven are the relevant set and only these two are missing it.

What you think should happen instead?

Both should raise the same way their siblings do, so that a payload from a newer Airflow fails loudly rather than being read under assumptions that no longer hold.

There is no impact today — both serializers are at the version they ship with, so no payload in the wild carries a higher one. This is about the next time either format changes: whoever bumps __version__ would reasonably expect the guard to already be there, and its absence would not be obvious from the diff.

Anything else?

The two files are the only ones where the check is missing, so the fix is to add the same guard the other nine already use. No behaviour changes for any payload that exists now.

Are you willing to submit PR?

Yes — PR to follow.

Activity

  1. bunnysayzz commented on Sep 8, 2026

    @bunnysayzz

    I'd like to take this. The fix is small: add the version > class_version guard to the uuid and datetime deserializers in task-sdk/src/airflow/sdk/serde/serializers/, matching the ten serializers that already reject newer-version payloads (same TypeError shape as bignum), with tests pinning the rejection for both. PR shortly.

  2. bunnysayzz commented on Sep 8, 2026

    @bunnysayzz

    Withdrawing my claim above, #72637 was already up before I commented and covers the same guard. Happy to help review or test it instead.

  3. bunnysayzz commented on Sep 30, 2026

    @bunnysayzz

    you are right, #72637 was already open when I claimed this. withdrawing mine.

  4. Darshanpawar7 commented on Nov 11, 2026

    @Darshanpawar7

    Hi @aniketwaghh, #72637 was closed by the stale bot on 3 Nov while it waited for another review, and the gap is still on main. uuid.py and datetime.py are still the only registered serializers that accept a payload stamped with a newer version than they know.

    Do you plan to reopen it? If you'd rather not continue, I'm happy to pick it up: I'd add the version > __version__ check to both deserializers, keep your test that goes through the public serde.deserialize() path, and credit your PR in the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions