{
  "id": "python/fastapi-duplicate-route-registration",
  "signature": "fastapi.exceptions.FastAPIError: Duplicate parameter name: 'item_id' in function 'read_item'",
  "signature_zh": "FastAPI错误：函数中参数名重复",
  "regex": "fastapi\\.exceptions\\.FastAPIError:\\ Duplicate\\ parameter\\ name:\\ 'item_id'\\ in\\ function\\ 'read_item'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Defining multiple path parameters with the same name in a single route handler (e.g., `@app.get('/items/{item_id}')` and then using `item_id` twice in the function signature) causes a duplicate parameter error.",
  "root_cause_type": "generic",
  "root_cause_zh": "在单个路由处理函数中定义多个同名路径参数（如`@app.get('/items/{item_id}')`并在函数签名中重复使用`item_id`）会导致重复参数错误。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Renaming the parameter in the function signature but not in the path decorator causes a mismatch and still raises an error.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using type hints like `item_id: int` doesn't resolve the duplicate; FastAPI still sees two parameters with the same name.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 1.0,
      "how": "Ensure each path parameter appears only once in the function signature. Example: `def read_item(item_id: int, q: str = None):`",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use distinct names for path and query parameters, e.g., `def read_item(item_id: int, query_param: str = None):`",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}