# AttributeError: 'Starlette' object has no attribute 'add_middleware'

- **ID:** `python/starlette-attributeerror-starlette-app-has-no-attribute-add-middleware`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Trying to use add_middleware method on a Starlette instance, but the method is not available in older versions or incorrect object.

## Version Compatibility

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

## Workarounds

1. **Use correct middleware registration syntax** (90% success)
   ```
   app.add_middleware(MiddlewareClass)
   ```
2. **Check Starlette version and upgrade if needed** (85% success)
   ```
   pip install --upgrade starlette
   ```

## Dead Ends

- **Assuming Starlette has the same API as Flask** — Starlette uses different middleware registration. (70% fail)
- **Using add_middleware on a middleware class instead of app** — Method exists on app, not middleware. (80% fail)
