{
  "id": "python/fastapi-pydantic-validation-int-parsing",
  "signature": "fastapi.exceptions.RequestValidationError: 1 validation error for Model\nbody -> age\n  value is not a valid integer (type=type_error.integer)",
  "signature_zh": "fastapi.exceptions.RequestValidationError: Model 的 1 个校验错误\nbody -> age\n  不是有效的整数 (type=type_error.integer)",
  "regex": "fastapi\\.exceptions\\.RequestValidationError:\\ 1\\ validation\\ error\\ for\\ Model\\\nbody\\ \\->\\ age\\\n\\ \\ value\\ is\\ not\\ a\\ valid\\ integer\\ \\(type=type_error\\.integer\\)",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A Pydantic int field receives a non-numeric string or float with fractional part from the JSON body.",
  "root_cause_type": "generic",
  "root_cause_zh": "Pydantic 的 int 字段从 JSON 请求体接收到非数字字符串或带小数的浮点数。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Downstream arithmetic fails with TypeError.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides bad data and corrupts records.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "requests.post(url, json={'age': int(age_str)})",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from pydantic import field_validator\n@field_validator('age', mode='before')\ndef parse_age(cls, v):\n    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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}