The Fix
pip install pydantic==2.11.4
Based on closed pydantic/pydantic issue #11765 · 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%.
@@ -194,7 +194,7 @@ class Model(BaseModel):
#> my_field='foo'
- m = Model(my_alias='foo') # (3)!
+ m = Model(my_field='foo') # (3)!
print(m)
pydantic version: 2.11.3
pydantic-core version: 2.33.1
pydantic-core build: profile=release pgo=false
install path: /home/vscode/.cache/pyuv/.venv/lib/python3.13/site-packages/pydantic
python version: 3.13.3 (main, Apr 9 2025, 04:03:52) [Clang 20.1.0 ]
platform: Linux-6.8.0-57-generic-x86_64-with-glibc2.36
related packages: pydantic-extra-types-2.10.3 fastapi-0.115.12 pydantic-settings-2.8.1 mypy-1.15.0 typing_extensions-4.13.2
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==2.11.4\nWhen NOT to use: This fix should not be used if the documentation is already correct.\n\n
Why This Fix Works in Production
- Trigger: Documentation error: Incorrect example in `populate_by_name` docstring
- Mechanism: The documentation example for `populate_by_name` incorrectly repeated the previous example instead of showing the correct field
- Why the fix works: Fixes the example in the `populate_by_name` documentation, correcting the third example to use `my_field` instead of `my_alias`. (first fixed release: 2.11.4).
- 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.13 in real deployments (not just unit tests).
- The documentation example for `populate_by_name` incorrectly repeated the previous example instead of showing the correct field
- Production symptom (often without a traceback): Documentation error: Incorrect example in `populate_by_name` docstring
Proof / Evidence
- GitHub issue: #11765
- Fix PR: https://github.com/pydantic/pydantic/pull/11766
- First fixed release: 2.11.4
- 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.61
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“### Initial Checks - [x] I confirm that I'm using Pydantic V2 ### Description In the docstring for the populate_by_name configuration setting in pydantic/config.py (lines 168-205), there is an error in the code example that demonstrates the”
Failure Signature (Search String)
- Documentation error: Incorrect example in `populate_by_name` docstring
Copy-friendly signature
Failure Signature
-----------------
Documentation error: Incorrect example in `populate_by_name` docstring
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Documentation error: Incorrect example in `populate_by_name` docstring
Minimal Reproduction
pydantic version: 2.11.3
pydantic-core version: 2.33.1
pydantic-core build: profile=release pgo=false
install path: /home/vscode/.cache/pyuv/.venv/lib/python3.13/site-packages/pydantic
python version: 3.13.3 (main, Apr 9 2025, 04:03:52) [Clang 20.1.0 ]
platform: Linux-6.8.0-57-generic-x86_64-with-glibc2.36
related packages: pydantic-extra-types-2.10.3 fastapi-0.115.12 pydantic-settings-2.8.1 mypy-1.15.0 typing_extensions-4.13.2
commit: unknown
Environment
- Python: 3.13
- Pydantic: 2
What Broke
Users were misled by incorrect documentation, potentially causing confusion in implementation.
Why It Broke
The documentation example for `populate_by_name` incorrectly repeated the previous example instead of showing the correct field
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.4
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/11766
First fixed release: 2.11.4
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the documentation is already correct.
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.11.4 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.