{
  "id": "python/starlette-middleware-type-error",
  "signature": "TypeError: 'Middleware' object is not callable",
  "signature_zh": "类型错误：'Middleware' 对象不可调用",
  "regex": "TypeError:\\ 'Middleware'\\ object\\ is\\ not\\ callable",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A middleware class is not instantiated or not used as a callable.",
  "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": "Passing the middleware class directly without instantiation.",
      "why_fails": "The middleware must be an instance or a callable; a class is not callable in this context.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Importing the middleware incorrectly from a wrong module.",
      "why_fails": "The imported object may not be a middleware at all.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Instantiate the middleware before adding it to the app.",
      "success_rate": 0.9,
      "how": "from starlette.middleware import Middleware\nmiddleware = Middleware(SomeMiddleware)\napp.add_middleware(middleware)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use the middleware class directly with app.add_middleware.",
      "success_rate": 0.95,
      "how": "app.add_middleware(SomeMiddleware)",
      "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-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}