{
  "id": "nextjs/server-action-formdata-parse-fail",
  "signature": "Error: Server Action failed to parse FormData: unexpected end of data",
  "signature_zh": "错误：服务器操作解析 FormData 失败：数据意外结束",
  "regex": "Error: Server Action failed to parse FormData: unexpected end of data",
  "domain": "nextjs",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The FormData sent to a Server Action is incomplete or malformed, often due to a client-side fetch or form submission that truncates the body before sending.",
  "root_cause_type": "generic",
  "root_cause_zh": "发送到服务器操作的 FormData 不完整或格式错误，通常是由于客户端 fetch 或表单提交在发送前截断了请求体。",
  "versions": [
    {
      "version": "next@14.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "next@14.2.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "next@15.0.0-rc.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding 'Content-Type: multipart/form-data' header manually in fetch calls",
      "why_fails": "The browser automatically sets the correct Content-Type with boundary for FormData; manually setting it can break parsing.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increasing server body parser size limit in next.config.js",
      "why_fails": "The error is not about size limits but about incomplete data transmission, often due to client-side logic errors.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Switching to JSON.stringify instead of FormData for the request body",
      "why_fails": "Server Actions expect FormData for 'use server' functions; sending JSON requires different handling and may cause type mismatches.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the client-side form submission uses the native FormData API correctly. For fetch, avoid manually setting headers: `const formData = new FormData(); formData.append('field', value); await fetch('/api/action', { method: 'POST', body: formData });`",
      "success_rate": 0.85,
      "how": "Ensure the client-side form submission uses the native FormData API correctly. For fetch, avoid manually setting headers: `const formData = new FormData(); formData.append('field', value); await fetch('/api/action', { method: 'POST', body: formData });`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Validate the FormData before sending by logging or checking entries: `for (let [key, value] of formData.entries()) { console.log(key, value); }` to confirm all fields are present.",
      "success_rate": 0.75,
      "how": "Validate the FormData before sending by logging or checking entries: `for (let [key, value] of formData.entries()) { console.log(key, value); }` to confirm all fields are present.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using a custom fetch, ensure no premature stream closing. Use `await fetch(url, { method: 'POST', body: formData })` without wrapping in JSON.stringify.",
      "success_rate": 0.8,
      "how": "If using a custom fetch, ensure no premature stream closing. Use `await fetch(url, { method: 'POST', body: formData })` without wrapping in JSON.stringify.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保客户端表单提交正确使用原生 FormData API。对于 fetch，避免手动设置头部：`const formData = new FormData(); formData.append('field', value); await fetch('/api/action', { method: 'POST', body: formData });`",
    "在发送前验证 FormData，通过日志或检查条目：`for (let [key, value] of formData.entries()) { console.log(key, value); }` 确认所有字段都存在。",
    "如果使用自定义 fetch，确保没有过早关闭流。使用 `await fetch(url, { method: 'POST', body: formData })`，不要用 JSON.stringify 包裹。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#formdata",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2024-06-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}