# json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

- **ID:** `python/starlette-request-body-parse-error`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Starlette 收到的请求体不是有效的 JSON 格式

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## Workarounds

1. **验证请求体格式并返回错误** (95% success)
   ```
   try:
    data = await request.json()
except JSONDecodeError:
    return JSONResponse({'error': '无效的 JSON'}, status_code=400)
   ```
2. **使用 Pydantic 模型自动验证** (90% success)
   ```
   from pydantic import BaseModel
class Item(BaseModel):
    name: str
item = Item.parse_raw(await request.body())
   ```

## Dead Ends

- **忽略错误并返回空数据** — 可能接受无效请求 (80% fail)
- **使用 eval 解析请求体** — 存在严重安全风险 (95% fail)
