{
  "id": "python/fastapi-response-validation-error",
  "signature": "fastapi.exceptions.ResponseValidationError: 2 validation errors for UserResponse\nid\n  value is not a valid integer (type=type_error.integer)",
  "signature_zh": "fastapi.exceptions.ResponseValidationError: 响应验证错误，返回数据不匹配响应模型。",
  "regex": "fastapi\\.exceptions\\.ResponseValidationError:\\ 2\\ validation\\ errors\\ for\\ UserResponse\\\nid\\\n\\ \\ value\\ is\\ not\\ a\\ valid\\ integer\\ \\(type=type_error\\.integer\\)",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The view returns data that does not conform to the declared response_model (wrong types, missing fields, or extra nested structure).",
  "root_cause_type": "generic",
  "root_cause_zh": "视图返回的数据不符合声明的 response_model（类型错误、字段缺失或嵌套结构不匹配）。",
  "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": "Still logs ResponseValidationError; clients get opaque failures.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Loses OpenAPI schema and silently returns wrong shapes.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Coerce in the view: `return UserResponse(id=int(user['id']), name=str(user['name']))` or use `.model_validate(user, from_attributes=True)`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Set `model_config = ConfigDict(from_attributes=True)` on the Pydantic model and return ORM objects directly.",
      "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-06-07",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}