Skip to content

[WORKFLOW SDK FEATURE REQUEST] Support pydantic models #858

Closed

Description

@leechristensen

Describe the WORKFLOW SDK feature

It would be convenient if workflows/activities could support Pydantic models as input, automatically handling the (de)serializaiton. Right now, they only support dictionaries or simple values. The motivation comes from wanting to use strongly typed objects vs dictionaries (which are more opaque in their types).

There is some precedent here with the FastAPI extension supporting them in subscriptions.

acceptance criteria:

  • workflows/activities use pydantic models as their inputs
  • we still support dictionaries and can serialize dictionaries into pydantic models
  • dapr quickstarts are all updated
  • dapr docs are all updated

Release Note

RELEASE NOTE: feat: workflows and activities support Pydantic models as their inputs

Activity

  1. acroca commented on Oct 30, 2025

    @acroca
    Member

    Thank you for opening the issue!

    I checked the Go and Java SDKs and they both support custom user objects, using JSON. But both Go and Java have an 'easy' way to support this out of the box, so it doesn't add a lot of complexity.
    I'm wondering if it'd be possible to support any sort of object that is serializable and deserializable using json, to add a more generic support to json->object instead of just pydantic. Any thoughts?

    Also, we need to make sure the pydantic dependency is optional.

  2. leechristensen commented on Oct 30, 2025

    @leechristensen
    Author

    Swappable serializers I'm sure would be welcome! I think adding a serializer arg to the subscribe method would be a good option, or expose a way to set that globally all across all subscribers.

    I'm wondering if it'd be possible to support any sort of object that is serializable and deserializable using json

    Is it necessary to restrict to JSON? I personally use Pydantic JSON objects the most, but Protobufs/Grpc are a close 2nd. Dapr uses Protobufs underneath IIRC so I feel like it slots in well there.

    Also, we need to make sure the pydantic dependency is optional.

    My preference would be to use Python extras to install the functionality. That way users could do something like:

    pip install 'dapr[pydantic-serializer]'
    

    But that does deviate away from how some of the current sdk extensions are implemented (i.e. as other pypi packages)

  3. olitomlinson commented on Dec 24, 2025

    @olitomlinson
    Contributor

    Big +1 for supporting Pydantic models and alternative serializers. Having consistency across the SDK is essential for good UX (and the precedent has already been set, so unless there is a good reason not to we should do this)

  4. dapr-bot commented on Mar 24, 2026

    @dapr-bot
    Collaborator

    This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

  5. removed
    staleIssue marked as stale by Dapr Bot
    on Mar 25, 2026
  6. added theissue type on Apr 1, 2026
  7. changed the issue type fromtoon Apr 1, 2026
  8. added this to the v1.18 milestone on Apr 1, 2026
  9. olitomlinson commented on Apr 16, 2026

    @olitomlinson
    Contributor

    @sicoyle @acroca I think the priority of this needs reconsidering.

    Folks will expect good Pydantic support out of the box. I find that I have to drop down to passing around dicts to get a good level of interoperability for cross-app workflows, which, is not great.

    Which leaves the code in an undesirable state... which isn't a joy to author for any one considering Dapr Workflows.

    Image
  10. self-assigned this
    on Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions