{
  "id": "python/fastapi-multiple-body-params",
  "signature": "TypeError: Multiple body parameters are not allowed when using Pydantic models.",
  "signature_zh": "类型错误: 使用Pydantic模型时不允许有多个body参数。",
  "regex": "TypeError:\\ Multiple\\ body\\ parameters\\ are\\ not\\ allowed\\ when\\ using\\ Pydantic\\ models\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "FastAPI路由中定义了多个Pydantic模型作为body参数，但HTTP请求只能有一个body。",
  "root_cause_type": "generic",
  "root_cause_zh": "FastAPI路由中定义了多个Pydantic模型作为body参数，但HTTP请求只能有一个body。",
  "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.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "使用多个非模型参数（如str）作为body",
      "why_fails": "FastAPI会将多个参数视为查询参数。",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "将多个模型合并为一个嵌套模型",
      "success_rate": 0.95,
      "how": "class Item(BaseModel): name: str; class User(BaseModel): username: str; class Combined(BaseModel): item: Item; user: User; @app.post('/create') async def create(data: Combined): return data",
      "condition": "",
      "sources": []
    },
    {
      "action": "使用Body参数分别标注",
      "success_rate": 0.9,
      "how": "from fastapi import Body; @app.post('/create') async def create(item: Item = Body(...), user: User = Body(...)): return {'item': item, 'user': user}",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}