Jump to solution
Verify

The Fix

pip install pydantic==2.9.2

Based on closed pydantic/pydantic issue #10385 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -190,10 +190,15 @@ def __get_pydantic_core_schema__(self, source_type: Any, handler: GetCoreSchemaH try: schema = handler(source_type) - serialization = core_schema.wrap_serializer_function_ser_schema( - function=lambda v, h: h(v), - schema=schema,
repro.py
from typing import Annotated from pydantic import BaseModel, PlainSerializer, PlainValidator def val(v): print(f'val {v}') return v def ser(v): print(f'ser {v}') return v class Model(BaseModel): a: Annotated[int, PlainSerializer(ser), PlainValidator(val)] m = Model(a=1) m.model_dump()
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install pydantic==2.9.2\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n

Why This Fix Works in Production

  • Trigger: Wrong ordering of serializer and validator in `Annotated` breaks serialized output
  • Mechanism: The serialization schema generation was incorrectly configured, causing double serialization calls
  • Why the fix works: Fix serialization schema generation when using `PlainValidator` to prevent double serialization calls. (first fixed release: 2.9.2).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • The serialization schema generation was incorrectly configured, causing double serialization calls
  • Production symptom (often without a traceback): Wrong ordering of serializer and validator in `Annotated` breaks serialized output

Proof / Evidence

Verified Execution

We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.

  • Status: PASS
  • Ran: 2026-02-11T16:52:29Z
  • Package: pydantic
  • Fixed: 2.9.2
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)
val 1 ser 1

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“@ngnpope, Thanks for reporting this! We'll work on a fix for v2.9.2!”
@sydney-runkle · 2024-09-11 · source
“@sydney-runkle, I believe this: Would fix the issue, but to be confirmed.”
@Viicos · 2024-09-12 · source

Failure Signature (Search String)

  • Wrong ordering of serializer and validator in `Annotated` breaks serialized output
  • serialization = core_schema.wrap_serializer_function_ser_schema(
Copy-friendly signature
signature.txt
Failure Signature ----------------- Wrong ordering of serializer and validator in `Annotated` breaks serialized output serialization = core_schema.wrap_serializer_function_ser_schema(

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Wrong ordering of serializer and validator in `Annotated` breaks serialized output serialization = core_schema.wrap_serializer_function_ser_schema(

Minimal Reproduction

repro.py
from typing import Annotated from pydantic import BaseModel, PlainSerializer, PlainValidator def val(v): print(f'val {v}') return v def ser(v): print(f'ser {v}') return v class Model(BaseModel): a: Annotated[int, PlainSerializer(ser), PlainValidator(val)] m = Model(a=1) m.model_dump()

Environment

  • Pydantic: 2

What Broke

Incorrect values were serialized due to multiple calls to the serializer.

Why It Broke

The serialization schema generation was incorrectly configured, causing double serialization calls

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install pydantic==2.9.2

When NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/pydantic/pydantic/pull/10427

First fixed release: 2.9.2

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use if it changes public behavior or if the failure cannot be reproduced.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
  • Upgrade behind a canary and run integration tests against the canary before 100% rollout.

Version Compatibility Table

VersionStatus
2.9.2 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.