{
  "id": "python/fastapi-request-validation-missing-field",
  "signature": "fastapi.exceptions.RequestValidationError: field required",
  "signature_zh": "FastAPI 请求验证错误：缺少必填字段。",
  "regex": "fastapi\\.exceptions\\.RequestValidationError:\\ field\\ required",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Request body or query parameters missing a required field defined in Pydantic model or function signature.",
  "root_cause_type": "generic",
  "root_cause_zh": "请求体或查询参数缺少 Pydantic 模型或函数签名中定义的必填字段。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "FastAPI raises RequestValidationError specifically; generic catches miss it and return 500.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides bugs and may not satisfy API contract; still fails if type mismatch.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from fastapi import FastAPI, Request\nfrom fastapi.exceptions import RequestValidationError\nfrom fastapi.responses import JSONResponse\n\n@app.exception_handler(RequestValidationError)\nasync def validation_exception_handler(request: Request, exc: RequestValidationError):\n    return JSONResponse(status_code=422, content={\"detail\": exc.errors()})",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Ensure required fields in Pydantic model: class Item(BaseModel):\n    name: str  # no default\n    price: float",
      "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-05-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}