{
  "id": "python/fastapi-request-body-too-large",
  "signature": "RuntimeError: Request body exceeded maximum size (1000000 bytes)",
  "signature_zh": "运行时错误：请求体超过最大大小（1000000字节）",
  "regex": "RuntimeError:\\ Request\\ body\\ exceeded\\ maximum\\ size\\ \\(1000000\\ bytes\\)",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The incoming request body is larger than the maximum allowed size set by the application.",
  "root_cause_type": "generic",
  "root_cause_zh": "传入的请求体大于应用设置的最大允许大小。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Truncating the request body on the client side",
      "why_fails": "May lose data; not a server-side fix.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignoring the error and retrying",
      "why_fails": "Same error will occur until limit is increased or body is reduced.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase the maximum request body size",
      "success_rate": 0.9,
      "how": "from starlette.middleware.base import BaseHTTPMiddleware\nclass LimitUploadSize(BaseHTTPMiddleware):\n    async def dispatch(self, request, call_next):\n        if request.headers.get('content-length'):\n            if int(request.headers['content-length']) > 10 * 1024 * 1024:\n                raise HTTPException(status_code=413, detail=\"Request too large\")\n        return await call_next(request)\napp.add_middleware(LimitUploadSize)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use streaming to handle large bodies",
      "success_rate": 0.8,
      "how": "async def upload():\n    async for chunk in request.stream():\n        process_chunk(chunk)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}