{
  "id": "python/fastapi-response-model-extra-forbidden",
  "signature": "fastapi.exceptions.ResponseValidationError: The server encountered an error while generating the response",
  "signature_zh": "FastAPI响应验证错误：服务器生成响应时出错",
  "regex": "fastapi\\.exceptions\\.ResponseValidationError:\\ The\\ server\\ encountered\\ an\\ error\\ while\\ generating\\ the\\ response",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The response model has `extra='forbid'` and the actual data contains extra fields not defined in the model, causing validation to fail.",
  "root_cause_type": "generic",
  "root_cause_zh": "响应模型设置了`extra='forbid'`，实际数据包含模型中未定义的额外字段，导致验证失败。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Removing the extra fields from the response data manually is error-prone and may not be the intended fix.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changing `extra='forbid'` to `extra='ignore'` in the model may hide the issue but could break client expectations.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Ensure the response data matches the model exactly, or use `response_model_exclude_unset=True` in the route decorator to omit unset fields.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Add the extra fields to the response model if they are expected.",
      "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-04-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}