{
  "id": "python/starlette-request-body-stream-error",
  "signature": "RuntimeError: Unable to read request body, please use the stream parameter.",
  "signature_zh": "运行时错误：无法读取请求体，请使用 stream 参数。",
  "regex": "RuntimeError:\\ Unable\\ to\\ read\\ request\\ body,\\ please\\ use\\ the\\ stream\\ parameter\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "尝试直接访问 request.body()，但请求体已经被消费。",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试直接访问 request.body()，但请求体已经被消费。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "请求体只能读取一次，第二次会抛出异常",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "stream 需要正确管理，否则会导致内存泄漏",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "async def body_middleware(request, call_next):\n    body = await request.body()\n    request._body = body\n    response = await call_next(request)\n    return response",
      "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.8,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-08-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}