# AssertionError: Route function must be async

- **ID:** `python/starlette-missing-route-handler`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A route handler in Starlette is defined as a synchronous function instead of async.

## Version Compatibility

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

## Workarounds

1. **Define the route handler as async** (95% success)
   ```
   @app.route('/')
async def homepage(request):
    return PlainTextResponse('Hello')
   ```
2. **Use a sync wrapper if absolutely necessary** (50% success)
   ```
   from starlette.responses import PlainTextResponse
@app.route('/')
def sync_homepage(request):
    return PlainTextResponse('Hello')
   ```

## Dead Ends

- **Adding @app.route without async** — Starlette requires async handlers; sync functions cause assertion errors. (90% fail)
- **Wrapping the function in a decorator that makes it async** — Complex and may not work correctly with Starlette's internals. (70% fail)
