{
  "id": "python/starlette-request-body-unavailable",
  "signature": "RuntimeError: Request body is not available after the request has been consumed",
  "signature_zh": "运行时错误：请求被消费后，请求体不可用",
  "regex": "RuntimeError:\\ Request\\ body\\ is\\ not\\ available\\ after\\ the\\ request\\ has\\ been\\ 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": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "会导致并发问题。",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "body = await request.body(); request._body = body 然后后续使用 request._body",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "确保只调用一次 await request.json() 或 body()",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}