# RuntimeError: Lifespan protocol not supported. Use 'lifespan' parameter.

- **ID:** `python/starlette-missing-lifespan`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Starlette applications require the lifespan parameter to be set when using async context managers for startup/shutdown.

## Version Compatibility

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

## Workarounds

1. **Define a lifespan context manager** (95% success)
   ```
   from contextlib import asynccontextmanager

@asynccontextmanager
async def lifespan(app):
    # startup
    yield
    # shutdown

app = Starlette(lifespan=lifespan)
   ```
2. **Use on_startup and on_shutdown callbacks** (90% success)
   ```
   app = Starlette(on_startup=[startup_func], on_shutdown=[shutdown_func])
   ```

## Dead Ends

- **Not using any lifespan parameter** — The application expects explicit lifespan handling. (100% fail)
- **Setting lifespan to a string like 'auto'** — The lifespan parameter must be a callable or None. (90% fail)
