The Fix
Adds support for the 'propertyNames' keyword in JSON schema, which is causing issues when converting Pydantic models with Enums into JSON.
Based on closed pydantic/pydantic issue #11337 · 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%.
@@ -958,17 +958,26 @@ def dict_schema(self, schema: core_schema.DictSchema) -> JsonSchemaValue:
json_schema: JsonSchemaValue = {'type': 'object'}
- keys_schema = self.generate_inner(schema['keys_schema']).copy() if 'keys_schema' in schema else {}
+ keys_schema = self.resolve_schema_to_update(
+ self.generate_inner(schema['keys_schema']).copy() if 'keys_schema' in schema else {}
pydantic version: 2.10.6
pydantic-core version: 2.27.2
pydantic-core build: profile=release pgo=false
install path: C:\Users\Micah\AppData\Local\pypoetry\Cache\virtualenvs\ds-utils-k-EZB9sN-py3.12\Lib\site-packages\pydantic
python version: 3.12.6 (tags/v3.12.6:a4a2d2b, Sep 6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)]
platform: Windows-10-10.0.19045-SP0
related packages: fastapi-0.115.7 pyright-1.1.329 typing_extensions-4.12.2
commit: unknown
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\nAdds support for the 'propertyNames' keyword in JSON schema, which is causing issues when converting Pydantic models with Enums into JSON.\nWhen NOT to use: This fix should not be used if the application requires the 'propertyNames' keyword for valid JSON schemas.\n\n
Why This Fix Works in Production
- Trigger: Disable support for "propertyNames" in 'model_json_schema()'
- Mechanism: The 'propertyNames' keyword in JSON schema is causing parsing failures in MongoDB
- 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 'propertyNames' keyword in JSON schema is causing parsing failures in MongoDB
- Production symptom (often without a traceback): Disable support for "propertyNames" in 'model_json_schema()'
Proof / Evidence
- GitHub issue: #11337
- Fix PR: https://github.com/pydantic/pydantic/pull/10478
- Reproduced locally: No (not executed)
- Last verified: 2026-02-11
- Confidence: 0.70
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.51
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Could you please provide a MRE giving the JSON Schema that fails?”
Failure Signature (Search String)
- Disable support for "propertyNames" in 'model_json_schema()'
- I am trying to convert a Pydantic model with ENums into JSON for updating the schema of a collection in MongoDB. The issue started occuring since this PR was merged:
Copy-friendly signature
Failure Signature
-----------------
Disable support for "propertyNames" in 'model_json_schema()'
I am trying to convert a Pydantic model with ENums into JSON for updating the schema of a collection in MongoDB. The issue started occuring since this PR was merged: https://github.com/pydantic/pydantic/pull/10478
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Disable support for "propertyNames" in 'model_json_schema()'
I am trying to convert a Pydantic model with ENums into JSON for updating the schema of a collection in MongoDB. The issue started occuring since this PR was merged: https://github.com/pydantic/pydantic/pull/10478
Minimal Reproduction
pydantic version: 2.10.6
pydantic-core version: 2.27.2
pydantic-core build: profile=release pgo=false
install path: C:\Users\Micah\AppData\Local\pypoetry\Cache\virtualenvs\ds-utils-k-EZB9sN-py3.12\Lib\site-packages\pydantic
python version: 3.12.6 (tags/v3.12.6:a4a2d2b, Sep 6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)]
platform: Windows-10-10.0.19045-SP0
related packages: fastapi-0.115.7 pyright-1.1.329 typing_extensions-4.12.2
commit: unknown
Environment
- Pydantic: 2
What Broke
Users experience errors when converting Pydantic models with Enums into JSON for MongoDB.
Why It Broke
The 'propertyNames' keyword in JSON schema is causing parsing failures in MongoDB
Fix Options (Details)
Option A — Apply the official fix
Adds support for the 'propertyNames' keyword in JSON schema, which is causing issues when converting Pydantic models with Enums into JSON.
Fix reference: https://github.com/pydantic/pydantic/pull/10478
Last verified: 2026-02-11. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the application requires the 'propertyNames' keyword for valid JSON schemas.
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.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.