{
  "id": "python/starlette-request-body-consume-error",
  "signature": "RuntimeError: Stream consumed",
  "signature_zh": "运行时错误：流已被消费",
  "regex": "RuntimeError:\\ Stream\\ consumed",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "在 Starlette 中多次读取请求体，而请求体只能读取一次。",
  "root_cause_type": "generic",
  "root_cause_zh": "在 Starlette 中多次读取请求体，而请求体只能读取一次。",
  "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.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "第二次调用会引发 RuntimeError。",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "不符合 ASGI 规范。",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "在第一次读取后缓存 body，如 request._body = await request.body()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "使用中间件一次性读取并将 body 存入 request.state",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "使用 ASGI 的 receive 包装器缓存请求体",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-02-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}