The Fix
pip install pydantic==1.10.1
Based on closed pydantic/pydantic issue #9572 · 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%.
@@ -34,7 +34,7 @@ A few notes:
Type coercion like this can be extremely helpful but also confusing or not desired,
-see [below](#coercion-and-stictness) for a discussion of `validate_arguments`'s limitations in this regard.
+see [below](#coercion-and-strictness) for a discussion of `validate_arguments`'s limitations in this regard.
from aenum import MultiValueEnum
from fastapi import Depends, FastAPI, Query, Request
from fastapi.responses import JSONResponse
from pydantic import BaseModel
class BooleanField(MultiValueEnum):
TRUE = "1", "True", "true", "Yes", 1
FALSE = "0", "False", "false", "No", 0
class Params(BaseModel):
field_1: BooleanField | None = None
@classmethod
def from_request(cls, field_1: str | None = Query(None)):
return cls(
field_1=BooleanField(field_1) if field_1 is not None else None
)
app = FastAPI()
@app.exception_handler(ValueError)
async def valuer_error_exception_handler(
request: Request, exc: Exception
) -> JSONResponse:
return JSONResponse(status_code=422, content={"message": f"{exc}"})
@app.get("/sample")
async def sample(q: Params = Depends(Params.from_request)) -> Params:
return q
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.1\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\nOption C — Workaround\nfor this this issue?\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: print(Sample(**{"field_1": 2, "field_2": "true", "field_3": "Yes", "field_4": "1"}))
- Mechanism: Addresses the validation issue with MultiValueEnum fields in Pydantic v2.7+ by ensuring proper handling of enum values.
- Why the fix works: Addresses the validation issue with MultiValueEnum fields in Pydantic v2.7+ by ensuring proper handling of enum values. (first fixed release: 1.10.1).
- 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
- Triggered by an upgrade/regression window: 2.7 breaks; 1.10.1 is the first fixed release.
- Shows up under Python 3.12 in real deployments (not just unit tests).
- Surfaces as: print(Sample(**{"field_1": 2, "field_2": "true", "field_3": "Yes", "field_4": "1"}))
Proof / Evidence
- GitHub issue: #9572
- Fix PR: https://github.com/pydantic/pydantic-core/pull/1456
- First fixed release: 1.10.1
- Affected versions: 2.7
- 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.34
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“It'll be because before v2.7 we just called the enum with the value so MultiValueEnum took care of validating that the value was allowed”
“Not at the moment, but I'll try to redo the enum validator in rust for v2.10 to support things like this. Thanks for following up!”
“@gbatagian, Yeah likely on our end, we made some major changes to enum handling in 2.7. Will look into a fix for this!”
“There is sort of a workaround within the Pydantic scope by manually casting the values into a multivalue enum through a field_validator: The value validation…”
Failure Signature (Search String)
- print(Sample(**{"field_1": 2, "field_2": "true", "field_3": "Yes", "field_4": "1"}))
Error Message
Stack trace
Error Message
-------------
print(Sample(**{"field_1": 2, "field_2": "true", "field_3": "Yes", "field_4": "1"}))
---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
Cell In[2], line 1
----> 1 print(Sample(**{"field_1": 2, "field_2": "true", "field_3": "Yes", "field_4": "1"}))
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pydantic/main.py:192, in BaseModel.__init__(self, **data)
190 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
191 __tracebackhide__ = True
--> 192 self.__pydantic_validator__.validate_python(data, self_instance=self)
ValidationError: 1 validation error for Sample
field_1
Value error, 2 is not a valid BooleanField [type=value_error, input_value=2, input_type=int]
For further information visit https://errors.pydantic.dev/2.8/v/value_error
Minimal Reproduction
from aenum import MultiValueEnum
from fastapi import Depends, FastAPI, Query, Request
from fastapi.responses import JSONResponse
from pydantic import BaseModel
class BooleanField(MultiValueEnum):
TRUE = "1", "True", "true", "Yes", 1
FALSE = "0", "False", "false", "No", 0
class Params(BaseModel):
field_1: BooleanField | None = None
@classmethod
def from_request(cls, field_1: str | None = Query(None)):
return cls(
field_1=BooleanField(field_1) if field_1 is not None else None
)
app = FastAPI()
@app.exception_handler(ValueError)
async def valuer_error_exception_handler(
request: Request, exc: Exception
) -> JSONResponse:
return JSONResponse(status_code=422, content={"message": f"{exc}"})
@app.get("/sample")
async def sample(q: Params = Depends(Params.from_request)) -> Params:
return q
Environment
- Python: 3.12
- Pydantic: 2.7
What Broke
Validation errors occur when using MultiValueEnum fields in Pydantic v2.7+.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.1
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Option C — Workaround Temporary workaround
for this this issue?
Use only if you cannot change versions today. Treat this as a stopgap and remove once upgraded.
Fix reference: https://github.com/pydantic/pydantic-core/pull/1456
First fixed release: 1.10.1
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.7 | Broken |
| 1.10.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.