Skip to content

Exclude computed fields from Pydantic payload JSON serialization - #2056

Open
rjrajput-web3 wants to merge 4 commits into
temporalio:mainfrom
rjrajput-web3:fix/2052-exclude-computed-fields
Open

rjrajput-web3 wants to merge 4 commits into
temporalio:mainfrom
rjrajput-web3:fix/2052-exclude-computed-fields

Conversation

@rjrajput-web3

Copy link
Copy Markdown

Fixes #2052. PydanticJSONPlainPayloadConverter wrote @computed_field values into payloads, which from_payload then rejected for models with extra='forbid'. This excludes computed fields during serialization (nested models included); they are recomputed on read. Verified byte-identical output to the previous serializer for everything except the removed computed fields (wire-format parity test passes), old payloads still deserialize, and adds a parametrized round-trip regression test. Requires pydantic>=2.11 for exclude_computed_fields support.

Updated to_payload method to use SchemaSerializer for JSON serialization.
Updated pydantic dependency version to 2.11.0.
Added tests for computed fields in Pydantic models, ensuring they are excluded during serialization.
Exclude computed fields from Pydantic JSON serialization to ensure models round-trip correctly with extra='forbid'. Requires pydantic>=2.11.
@rjrajput-web3
rjrajput-web3 requested a review from a team as a code owner October 31, 2026 07:49
@CLAassistant

CLAassistant commented Oct 31, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Pydantic converter writes computed fields that models with extra="forbid" then reject

2 participants