python
runtime_error
ai_generated
true
fastapi.exceptions.HTTPException: 422 Unprocessable Entity
ID: python/fastapi-http-exception-detail
80%Fix Rate
88%Confidence
0Evidence
2024-09-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 0.100.x | active | — | — | — |
| 0.110.x | active | — | — | — |
Root Cause
Request validation failed; FastAPI returns 422 when Pydantic validation fails.
generic中文
请求验证失败;当 Pydantic 验证失败时 FastAPI 返回 422。
Workarounds
-
95% success
The JSON response contains the specific field and error.
-
90% success
Use the /docs interface to test payloads.
Dead Ends
Common approaches that don't work:
-
70% fail
Changes status code but not the underlying validation error.
-
90% fail
Irrelevant to request validation.