{
  "id": "python/starlette-typeerror-middleware-must-be-callable",
  "signature": "TypeError: Middleware must be callable",
  "signature_zh": "类型错误：中间件必须是可调用的",
  "regex": "TypeError:\\ Middleware\\ must\\ be\\ callable",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Passing a non-callable object (e.g., a class instance without __call__) as middleware.",
  "root_cause_type": "generic",
  "root_cause_zh": "传递了一个不可调用的对象（例如没有__call__方法的类实例）作为中间件。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Passing a class directly instead of an instance",
      "why_fails": "Class itself is callable, but may not be the intended usage.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a string as middleware",
      "why_fails": "String is not callable.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Pass a middleware class or function",
      "success_rate": 0.9,
      "how": "app.add_middleware(MyMiddleware)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure middleware class has __call__ method",
      "success_rate": 0.85,
      "how": "class MyMiddleware:\n    async def __call__(self, scope, receive, send):\n        # implementation\n        pass",
      "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": "2025-09-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}