{
  "id": "python/fastapi-dependency-overrides-not-applied",
  "signature": "AssertionError: Dependency override for <function get_db at 0x...> was not applied; test used real database connection.",
  "signature_zh": "断言错误：依赖覆盖未生效，测试使用了真实数据库连接。",
  "regex": "AssertionError:\\ Dependency\\ override\\ for\\ <function\\ get_db\\ at\\ 0x\\.\\.\\.>\\ was\\ not\\ applied;\\ test\\ used\\ real\\ database\\ connection\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "app.dependency_overrides keyed on a different function object than the one used in the route (e.g., re-imported module or wrapped dependency).",
  "root_cause_type": "generic",
  "root_cause_zh": "app.dependency_overrides 使用的键与路由中实际使用的函数对象不同（例如模块被重新导入或依赖被包装）。",
  "versions": [
    {
      "version": "0.100.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "0.110.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "FastAPI requires the callable object, not its name.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "TestClient uses the app passed to it; overrides elsewhere are ignored.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from app.deps import get_db\napp.dependency_overrides[get_db] = lambda: test_session\nclient = TestClient(app)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use `app.dependency_overrides.clear()` in teardown to avoid leakage between tests.",
      "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": "2025-06-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}