{
  "id": "python/starlette-request-body-already-read",
  "signature": "RuntimeError: Stream consumed",
  "signature_zh": "RuntimeError: 流已被消费",
  "regex": "RuntimeError:\\ Stream\\ consumed",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Middleware read the request body with await request.body() or request.stream(), then the route tried to read it again; the ASGI receive stream is one-shot.",
  "root_cause_type": "generic",
  "root_cause_zh": "中间件使用 await request.body() 或 request.stream() 读取了请求正文，然后路由再次尝试读取；ASGI 接收流是一次性的。",
  "versions": [
    {
      "version": "0.30+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Second call returns empty bytes and downstream parsing fails.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Race conditions across concurrent requests corrupt data.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "async def dispatch(self, request, call_next):\n    body = await request.body()\n    async def receive():\n        return {'type':'http.request','body':body}\n    request._receive = receive\n    return await call_next(request)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "raw = await request.body()\ndata = json.loads(raw)",
      "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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}