Jump to solution
Verify

The Fix

pip install pydantic==1.10.19

Based on closed pydantic/pydantic issue #10434 · 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
@@ -127,6 +127,13 @@ def __get_pydantic_core_schema__(self, source_type: Any, handler: GetCoreSchemaH else handler.generate_schema(self.json_schema_input_type) ) + # Try to resolve the original schema if required, because schema cleaning + # won't inline references in metadata: + if input_schema is not None:
repro.py
from typing import Annotated from pydantic import BaseModel, PlainSerializer, PlainValidator class EmbeddedModel(BaseModel): id: int name: str def val(v): print(f'val {v}') # in my real code I get fk_id and replace it to EmbeddedModel instance return v def ser(v): print(f'ser {v}') return v class Model(BaseModel): fk_id: Annotated[ EmbeddedModel, PlainSerializer(ser, return_type=EmbeddedModel), PlainValidator(val, json_schema_input_type=EmbeddedModel), ] # m = Model.validate_model({fk_id:1}) m = Model(fk_id=EmbeddedModel(id=1, name='my embed')) print(m.model_json_schema())
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==1.10.19\nWhen NOT to use: Do not use this fix if your model relies on complex nested references that cannot be resolved.\n\n

Why This Fix Works in Production

  • Trigger: Plain serializer and validator in Annotated does not work with pydantic model
  • Mechanism: The schema generation fails due to unresolved references in the PlainSerializer and PlainValidator
  • Why the fix works: Inlines references when generating schema for json_schema_input_type, resolving issues with JSON Schema generation. (first fixed release: 1.10.19).
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

  • Shows up under Python 3.12 in real deployments (not just unit tests).
  • The schema generation fails due to unresolved references in the PlainSerializer and PlainValidator
  • Production symptom (often without a traceback): Plain serializer and validator in Annotated does not work with pydantic model

Proof / Evidence

Discussion

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

“### Initial Checks - [X] I confirm that I'm using Pydantic V2 ### Description I'm trying to use plain validator as hook to do some transformation for example return object instead of id. In example below i just define simplified example tha”
Issue thread · issue description · source

Failure Signature (Search String)

  • Plain serializer and validator in Annotated does not work with pydantic model
  • PlainValidator(val, json_schema_input_type=EmbeddedModel),
Copy-friendly signature
signature.txt
Failure Signature ----------------- Plain serializer and validator in Annotated does not work with pydantic model PlainValidator(val, json_schema_input_type=EmbeddedModel),

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Plain serializer and validator in Annotated does not work with pydantic model PlainValidator(val, json_schema_input_type=EmbeddedModel),

Minimal Reproduction

repro.py
from typing import Annotated from pydantic import BaseModel, PlainSerializer, PlainValidator class EmbeddedModel(BaseModel): id: int name: str def val(v): print(f'val {v}') # in my real code I get fk_id and replace it to EmbeddedModel instance return v def ser(v): print(f'ser {v}') return v class Model(BaseModel): fk_id: Annotated[ EmbeddedModel, PlainSerializer(ser, return_type=EmbeddedModel), PlainValidator(val, json_schema_input_type=EmbeddedModel), ] # m = Model.validate_model({fk_id:1}) m = Model(fk_id=EmbeddedModel(id=1, name='my embed')) print(m.model_json_schema())

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

Users experience serialization errors leading to application crashes.

Why It Broke

The schema generation fails due to unresolved references in the PlainSerializer and PlainValidator

Fix Options (Details)

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

pip install pydantic==1.10.19

When NOT to use: Do not use this fix if your model relies on complex nested references that cannot be resolved.

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/10439

First fixed release: 1.10.19

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 this fix if your model relies on complex nested references that cannot be resolved.

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
1.10.19 Fixed

Related Issues

No related fixes found.

Sources

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