{
  "id": "python/fastapi-422-unprocessable-entity",
  "signature": "HTTP/1.1 422 Unprocessable Entity\n{\"detail\":[{\"loc\":[\"body\",\"age\"],\"msg\":\"value is not a valid integer\",\"type\":\"type_error.integer\"}]}",
  "signature_zh": "HTTP 422 无法处理的实体：请求体字段类型验证失败。",
  "regex": "HTTP/1\\.1\\ 422\\ Unprocessable\\ Entity\\\n\\{\"detail\":\\[\\{\"loc\":\\[\"body\",\"age\"\\],\"msg\":\"value\\ is\\ not\\ a\\ valid\\ integer\",\"type\":\"type_error\\.integer\"\\}\\]\\}",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Client sent a value whose type does not match the Pydantic field (e.g., string for int, null for non-optional).",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端发送的值与 Pydantic 字段类型不匹配（例如给 int 传字符串，给非可选字段传 null）。",
  "versions": [
    {
      "version": "0.100.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "0.110.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Validation runs before the handler; decorator status does not apply.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides the real cause; clients still send wrong types.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use `age: int = Field(..., ge=0)` and document; client should send `{\"age\": 30}` not `{\"age\": \"30\"}` unless using `model_config = ConfigDict(coerce_numbers_to_str=False)` with custom validator.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Add a custom validator: `@field_validator('age', mode='before') def coerce(cls, v): return int(v)`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-12-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}