{
  "id": "python/fastapi-file-response-error",
  "signature": "RuntimeError: File response is already started",
  "signature_zh": "运行时错误：文件响应已启动。",
  "regex": "RuntimeError:\\ File\\ response\\ is\\ already\\ started",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "尝试在响应已经开始发送后再次修改或发送文件。",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试在响应已经开始发送后再次修改或发送文件。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "尝试在返回 `FileResponse` 后继续写入响应，导致错误。",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "尝试在流式响应中使用 `yield` 但未正确管理生成器。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "确保只返回一次 `FileResponse`，不要在返回后修改。",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "使用 `StreamingResponse` 并正确管理生成器生命周期。",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2026-03-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}