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%.
@@ -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,
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()
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
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).
- 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
- GitHub issue: #10385
- Fix PR: https://github.com/pydantic/pydantic/pull/10427
- First fixed release: 2.9.2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.59
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
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, I believe this: Would fix the issue, but to be confirmed.”
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
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 Message
-------------
Wrong ordering of serializer and validator in `Annotated` breaks serialized output
serialization = core_schema.wrap_serializer_function_ser_schema(
Minimal Reproduction
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
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.
When NOT to Use This Fix
- Do not use if it changes public behavior or if the failure cannot be reproduced.
Verify Fix
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
| Version | Status |
|---|---|
| 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.