# RequestEntityTooLarge: Request body is too large

- **ID:** `python/flask-upload-file-too-large`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

上传文件大小超过Flask配置的MAX_CONTENT_LENGTH限制

## Version Compatibility

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

## Workarounds

1. **增加MAX_CONTENT_LENGTH配置** (95% success)
   ```
   app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024  # 16MB
   ```
2. **在请求处理前检查文件大小** (90% success)
   ```
   @app.before_request
def check_content_length():
    if request.content_length > 10 * 1024 * 1024:
        abort(413)
   ```

## Dead Ends

- **在客户端限制文件大小但未修改服务器配置** — 客户端限制不能阻止恶意请求 (50% fail)
- **使用try-except捕获RequestEntityTooLarge** — Flask在请求处理前就拒绝，无法在视图中捕获 (40% fail)
