python data_error ai_generated true

starlette.exceptions.HTTPException: 422 Unprocessable Entity

ID: python/starlette-request-validation-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2025-02-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

请求体或参数验证失败,例如缺少必填字段。

generic

中文

请求体或参数验证失败,例如缺少必填字段。

Workarounds

  1. 95% success
    from pydantic import BaseModel
    class Item(BaseModel):
        name: str
        price: float = Field(..., gt=0)

Dead Ends

Common approaches that don't work:

  1. 90% fail

    会导致数据不完整,业务逻辑错误

  2. 80% fail

    不解决验证问题,只是绕过