Skip to content

Support MutableMapping and MutableSequence container traversal in JsonDataConverter and type discovery #352

Closed as not planned

Description

Description

While JsonDataConverter.can_reconstruct() and _coerce_generic() in durabletask/serialization.py support dict / Mapping, tuple, and list / Sequence containers, they currently omit collections.abc.MutableMapping and collections.abc.MutableSequence.

Because typing.get_origin() resolves MutableMapping[str, Model] to collections.abc.MutableMapping and MutableSequence[Model] to collections.abc.MutableSequence, can_reconstruct() returns False for these annotations:

conv = JsonDataConverter()
conv.can_reconstruct(MutableMapping[str, MyModel])  # returns False
conv.can_reconstruct(MutableSequence[MyModel])      # returns False

As a consequence:

  1. Inbound type discovery in type_discovery.activity_input_type() and orchestrator_input_type() ignores these parameter annotations and returns None. Activities and orchestrators receiving input payloads annotated as MutableMapping or MutableSequence receive raw dicts and lists rather than coerced model instances.
  2. Direct deserialization via converter.deserialize(payload, target_type=MutableMapping[str, MyModel]) leaves the inner values uncoerced.

Expected Behavior

JsonDataConverter.can_reconstruct() should recognize MutableMapping and MutableSequence annotations when their value/element types are reconstructable. In addition, _coerce_generic() should recursively coerce items for MutableMapping and MutableSequence container types.

Activity

  1. added
    breaking-change
    on Nov 23, 2026
  2. andystaples commented on Nov 23, 2026

    @andystaples
    Contributor

    Hi Hardik K (@hardikkaurani)
    Accepting this PR in a minor would require another opt-in flag for the serializer, as we did for #310. Given the complexity of continuing to add opt-in serializer features, we had a protracted discussion about our serialization policy and settled on what's now documented by #355 . New additions to types supported by JsonDataConverter will be deferred indefinitely, until we start preparing for a new breaking change major release, and we will be accepting potentially-breaking change fixes for serialization of supported types only going forward, as we did in #346.

    Closing the issue as not planned, customers who need MutableMapping and MutableSequence support can still get it via to_json/from_json implementations on their concrete classes, or a custom serializer.

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

    breaking-change

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions