{
  "id": "python/fastapi-depends-invalid-parameter",
  "signature": "fastapi.exceptions.FastAPIError: Invalid args for response field 'depends'",
  "signature_zh": "FastAPI错误：响应字段参数无效",
  "regex": "fastapi\\.exceptions\\.FastAPIError:\\ Invalid\\ args\\ for\\ response\\ field\\ 'depends'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Using `Depends()` incorrectly, such as passing a non-callable or using it in a response model, causes FastAPI to raise an error.",
  "root_cause_type": "generic",
  "root_cause_zh": "错误使用`Depends()`，如传递非可调用对象或在响应模型中使用，导致FastAPI抛出错误。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Using `Depends` as a type hint without parentheses, e.g., `def endpoint(dep: Depends):` fails because Depends is a class, not a type.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Putting `Depends` in a Pydantic model field doesn't work; it's only for route parameters.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 1.0,
      "how": "Use `Depends()` correctly: `def endpoint(dep: SomeClass = Depends())` or `def endpoint(dep: SomeClass = Depends(get_dep))`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Ensure the dependency function is callable and has correct signature.",
      "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-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}