# UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

- **ID:** `python/fastapi-unicodedecodeerror-request-body`
- **Domain:** python
- **Category:** encoding_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Request body contains non-UTF-8 encoded data, such as binary or Latin-1.

## Version Compatibility

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

## Workarounds

1. **Specify encoding when reading request body** (85% success)
   ```
   data = await request.body()
text = data.decode('latin-1')  # or 'utf-8' with errors='replace'
   ```
2. **Use FastAPI's bytes type for raw data** (90% success)
   ```
   from fastapi import UploadFile
@app.post('/upload')
async def upload(file: UploadFile):
    content = await file.read()
    # handle bytes as needed
   ```

## Dead Ends

- **Setting app default encoding to latin-1 globally** — Breaks other parts expecting UTF-8. (70% fail)
- **Ignoring errors with errors='ignore'** — Data loss can occur. (60% fail)
