# TypeError: Middleware must be callable

- **ID:** `python/starlette-typeerror-middleware-must-be-callable`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Passing a non-callable object (e.g., a class instance without __call__) as middleware.

## Version Compatibility

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

## Workarounds

1. **Pass a middleware class or function** (90% success)
   ```
   app.add_middleware(MyMiddleware)
   ```
2. **Ensure middleware class has __call__ method** (85% success)
   ```
   class MyMiddleware:
    async def __call__(self, scope, receive, send):
        # implementation
        pass
   ```

## Dead Ends

- **Passing a class directly instead of an instance** — Class itself is callable, but may not be the intended usage. (50% fail)
- **Using a string as middleware** — String is not callable. (90% fail)
