The Fix
pip install pydantic==1.10.24
Based on closed pydantic/pydantic issue #12218 · 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%.
@@ -1028,8 +1028,7 @@ def _serialize(v: Any) -> str:
elif v.name == '<stderr>':
return 'sys.stderr'
- else:
- return v
+ return v
pydantic version: 2.11.7
pydantic-core version: 2.33.2
pydantic-core build: profile=release pgo=false
python version: 3.12.11 (stable, redacted, redacted) [Clang 9999.0.0 (fc44a4fcd3c54be927c15ddd9211aca1501633e7)]
platform: Linux-5.10.0-smp-1107.69.0.0-x86_64-with-glibc2.27
related packages:
commit: unknown
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==1.10.24\nWhen NOT to use: Do not use this fix if the type's name attribute is expected to be handled differently.\n\n
Why This Fix Works in Production
- Trigger: `ImportString` serialization is incorrect when type has `name` attribute
- Mechanism: The serialization method for ImportString returned None for types with a name attribute not in handled cases
- Why the fix works: Fixes the serialization issue in `ImportString` when the type has a `name` attribute, ensuring it no longer returns None for unhandled cases. (first fixed release: 1.10.24).
- 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 method for ImportString returned None for types with a name attribute not in handled cases
- Production symptom (often without a traceback): `ImportString` serialization is incorrect when type has `name` attribute
Proof / Evidence
- GitHub issue: #12218
- Fix PR: https://github.com/pydantic/pydantic/pull/12219
- First fixed release: 1.10.24
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.65
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“The fix is trivial. Please see PR #12219.”
Failure Signature (Search String)
- `ImportString` serialization is incorrect when type has `name` attribute
Copy-friendly signature
Failure Signature
-----------------
`ImportString` serialization is incorrect when type has `name` attribute
Error Message
Signature-only (no traceback captured)
Error Message
-------------
`ImportString` serialization is incorrect when type has `name` attribute
Minimal Reproduction
pydantic version: 2.11.7
pydantic-core version: 2.33.2
pydantic-core build: profile=release pgo=false
python version: 3.12.11 (stable, redacted, redacted) [Clang 9999.0.0 (fc44a4fcd3c54be927c15ddd9211aca1501633e7)]
platform: Linux-5.10.0-smp-1107.69.0.0-x86_64-with-glibc2.27
related packages:
commit: unknown
Environment
- Pydantic: 2
What Broke
Serialization failures led to incorrect handling of types with a name attribute, causing potential data loss.
Why It Broke
The serialization method for ImportString returned None for types with a name attribute not in handled cases
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.24
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/12219
First fixed release: 1.10.24
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if the type's name attribute is expected to be handled differently.
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 |
|---|---|
| 1.10.24 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.