{
  "id": "python/fastapi-upload-file-size-limit",
  "signature": "fastapi.exceptions.HTTPException: 413 Request Entity Too Large",
  "signature_zh": "FastAPI HTTP 异常：请求实体过大",
  "regex": "fastapi\\.exceptions\\.HTTPException:\\ 413\\ Request\\ Entity\\ Too\\ Large",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "上传的文件大小超过了 FastAPI 或服务器的限制",
  "root_cause_type": "generic",
  "root_cause_zh": "上传的文件大小超过了 FastAPI 或服务器的限制",
  "versions": [
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "在前端压缩文件但后端限制未改",
      "why_fails": "压缩后仍可能超过限制，且质量下降",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "忽略错误并重试上传",
      "why_fails": "每次都会失败，浪费带宽",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "使用 UploadFile 并设置最大大小",
      "success_rate": 0.9,
      "how": "from fastapi import UploadFile, File\napp = FastAPI()\n@app.post('/upload')\nasync def upload(file: UploadFile = File(...)):\n    if file.size > 10 * 1024 * 1024:\n        raise HTTPException(413, '文件太大')",
      "condition": "",
      "sources": []
    },
    {
      "action": "配置服务器限制",
      "success_rate": 0.95,
      "how": "uvicorn.run(app, limit_max_request_body=10*1024*1024)",
      "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-01-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}