{
  "id": "python/starlette-request-body-already-consumed",
  "signature": "RuntimeError: The request body has already been consumed.",
  "signature_zh": "运行时错误：请求体已被消费。",
  "regex": "RuntimeError:\\ The\\ request\\ body\\ has\\ already\\ been\\ consumed\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "在 Starlette 中，多次读取请求体（如先调用 await request.json() 再调用 await request.body()）导致流已关闭。",
  "root_cause_type": "generic",
  "root_cause_zh": "在 Starlette 中，多次读取请求体（如先调用 await request.json() 再调用 await 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": "复制对象不会复制内部流状态，仍然无法读取。",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "body = await request.body()\ndata = json.loads(body)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "data = await request.json()\n# 如果需要再次使用，保存在变量中",
      "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-12-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}