{
  "id": "python/fastapi-depends-missing-parameter",
  "signature": "TypeError: missing 1 required positional argument: 'db'",
  "signature_zh": "类型错误：缺少1个必需的位置参数：'db'",
  "regex": "TypeError:\\ missing\\ 1\\ required\\ positional\\ argument:\\ 'db'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A dependency function expects a parameter that is not provided by the caller or the dependency injection system.",
  "root_cause_type": "generic",
  "root_cause_zh": "依赖函数期望一个参数，但调用方或依赖注入系统未提供。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding a default value to the parameter",
      "why_fails": "May not solve the underlying issue if the dependency is required.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Removing the dependency from the route",
      "why_fails": "Breaks the functionality that requires the dependency.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the dependency is properly injected using Depends",
      "success_rate": 0.95,
      "how": "from fastapi import Depends\nasync def get_db():\n    return db\n@app.get('/items')\nasync def read_items(db=Depends(get_db)):",
      "condition": "",
      "sources": []
    },
    {
      "action": "Define the dependency as a class with __call__",
      "success_rate": 0.85,
      "how": "class DBSession:\n    def __call__(self):\n        return db\n@app.get('/items')\nasync def read_items(db=Depends(DBSession())):",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-25",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}