{
  "id": "python/fastapi-response-model-validation",
  "signature": "fastapi.exceptions.ResponseValidationError: Response model validation failed: field 'email' is not a valid email address",
  "signature_zh": "FastAPI响应验证错误：响应模型验证失败：字段'email'不是有效的电子邮件地址",
  "regex": "fastapi\\.exceptions\\.ResponseValidationError:\\ Response\\ model\\ validation\\ failed:\\ field\\ 'email'\\ is\\ not\\ a\\ valid\\ email\\ address",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "FastAPI响应数据不符合响应模型中的验证规则",
  "root_cause_type": "generic",
  "root_cause_zh": "FastAPI响应数据不符合响应模型中的验证规则",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "在响应模型中移除验证规则",
      "why_fails": "移除验证会降低数据质量",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "使用try-except捕获响应错误",
      "why_fails": "验证在响应发送前执行，无法在应用层捕获",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "确保数据符合模型验证规则",
      "success_rate": 0.95,
      "how": "from pydantic import EmailStr\nclass UserOut(BaseModel):\n    email: EmailStr\nuser = UserOut(email='valid@example.com')",
      "condition": "",
      "sources": []
    },
    {
      "action": "使用response_model_exclude_unset选项",
      "success_rate": 0.85,
      "how": "@app.get('/user', response_model=UserOut, response_model_exclude_unset=True)",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}