{
  "id": "python/starlette-assertionerror-app-not-mounted",
  "signature": "AssertionError: ASGI app not mounted on lifespan",
  "signature_zh": "AssertionError: ASGI 应用未挂载到生命周期",
  "regex": "AssertionError:\\ ASGI\\ app\\ not\\ mounted\\ on\\ lifespan",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Lifespan handler is not properly configured in the Starlette application.",
  "root_cause_type": "generic",
  "root_cause_zh": "Starlette 应用程序中的生命周期处理程序未正确配置。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding lifespan without async context manager",
      "why_fails": "Lifespan requires async generator or context manager.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignoring lifespan entirely",
      "why_fails": "Some servers require lifespan for startup/shutdown.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Implement lifespan correctly",
      "success_rate": 0.9,
      "how": "from contextlib import asynccontextmanager\n@asynccontextmanager\nasync def lifespan(app):\n    # startup\n    yield\n    # shutdown\napp = Starlette(lifespan=lifespan)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use on_startup and on_shutdown directly",
      "success_rate": 0.85,
      "how": "async def startup():\n    print('start')\napp.add_event_handler('startup', startup)\napp.add_event_handler('shutdown', lambda: print('stop'))",
      "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.8,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-28",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}