# AssertionError: ASGI app not mounted on lifespan

- **ID:** `python/starlette-assertionerror-app-not-mounted`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Lifespan handler is not properly configured in the Starlette application.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Implement lifespan correctly** (90% success)
   ```
   from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(app):
    # startup
    yield
    # shutdown
app = Starlette(lifespan=lifespan)
   ```
2. **Use on_startup and on_shutdown directly** (85% success)
   ```
   async def startup():
    print('start')
app.add_event_handler('startup', startup)
app.add_event_handler('shutdown', lambda: print('stop'))
   ```

## Dead Ends

- **Adding lifespan without async context manager** — Lifespan requires async generator or context manager. (80% fail)
- **Ignoring lifespan entirely** — Some servers require lifespan for startup/shutdown. (60% fail)
