# TypeError: 'coroutine' object is not callable

- **ID:** `python/fastapi-middleware-missing-await`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

FastAPI middleware function is defined as async but not awaited when calling the next middleware or request handler.

## Version Compatibility

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

## Workarounds

1. **Ensure middleware function uses await when calling call_next** (95% success)
   ```
   @app.middleware('http')
async def add_process_time_header(request: Request, call_next):
    response = await call_next(request)
    return response
   ```
2. **Use synchronous middleware with proper decorator** (70% success)
   ```
   @app.middleware('http')
def sync_middleware(request: Request, call_next):
    response = call_next(request)
    return response
   ```

## Dead Ends

- **Adding @app.middleware('http') without async def** — FastAPI expects an async function for middleware; synchronous functions cause different errors. (80% fail)
- **Removing async keyword from middleware function** — Middleware becomes synchronous but FastAPI still treats it as async, leading to runtime issues. (75% fail)
