{
  "id": "python/fastapi-file-upload-empty",
  "signature": "fastapi.exceptions.RequestValidationError: [{'type': 'value_error.missing', 'loc': ['body', 'file'], 'msg': 'field required', 'input': None}]",
  "signature_zh": "FastAPI请求验证错误：缺少文件字段",
  "regex": "fastapi\\.exceptions\\.RequestValidationError:\\ \\[\\{'type':\\ 'value_error\\.missing',\\ 'loc':\\ \\['body',\\ 'file'\\],\\ 'msg':\\ 'field\\ required',\\ 'input':\\ None\\}\\]",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The endpoint expects a file upload via `UploadFile` but the request doesn't include a file part in the multipart form data.",
  "root_cause_type": "generic",
  "root_cause_zh": "端点期望通过`UploadFile`上传文件，但请求的multipart表单数据中没有包含文件部分。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Sending the file as a JSON body doesn't work; FastAPI expects multipart form data.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using `requests.post(url, files={'file': open('file.txt', 'rb')})` may fail if the field name doesn't match the parameter name.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Ensure the client sends multipart form data with the correct field name. For testing: `client.post('/upload', files={'file': ('filename.txt', b'content', 'text/plain')})`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Make the file parameter optional: `file: UploadFile = File(None)`.",
      "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-03-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}