# KeyError: 'Authorization'

- **ID:** `python/starlette-request-headers-missing`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在 Starlette 中直接访问 request.headers['Authorization']，但请求未包含该头部。

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   auth = request.headers.get('Authorization')
if auth is None:
    return JSONResponse({'error': 'missing'}, status_code=401)
   ```
2. **** (90% success)
   ```
   auth = request.headers.get('Authorization', '')
   ```

## Dead Ends

- **** — 头部名称不区分大小写，但拼写错误会导致返回 None，后续逻辑出错。 (50% fail)
- **** — 未处理缺失头部的情况，可能导致未授权访问。 (60% fail)
