{
  "id": "python/fastapi-request-validation-error-field-required",
  "signature": "fastapi.exceptions.RequestValidationError: 1 validation error for Request\nbody -> field_name\n  field required (type=value_error.missing)",
  "signature_zh": "FastAPI 请求验证错误：请求体中缺少必需字段 'field_name'",
  "regex": "fastapi\\.exceptions\\.RequestValidationError:\\ 1\\ validation\\ error\\ for\\ Request\\\nbody\\ \\->\\ field_name\\\n\\ \\ field\\ required\\ \\(type=value_error\\.missing\\)",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "客户端请求体缺少 Pydantic 模型定义的必需字段",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端请求体缺少 Pydantic 模型定义的必需字段",
  "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": "在请求头中添加 Content-Type 但不修改请求体",
      "why_fails": "字段缺失的根本问题未解决，验证依然失败",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "将字段类型改为 Optional 而不更新文档",
      "why_fails": "改变了接口契约，可能导致前端与后端不一致",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "在请求体中包含所有必需字段",
      "success_rate": 0.95,
      "how": "{\"field_name\": \"value\", \"other_field\": 123}",
      "condition": "",
      "sources": []
    },
    {
      "action": "在 Pydantic 模型中为字段设置默认值",
      "success_rate": 0.9,
      "how": "from pydantic import BaseModel\nclass Item(BaseModel):\n    field_name: str = \"default\"",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}