{
  "id": "python/flask-request-files-error",
  "signature": "werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: KeyError: 'file'",
  "signature_zh": "Werkzeug异常：400错误请求：键错误：'file'",
  "regex": "werkzeug\\.exceptions\\.BadRequestKeyError:\\ 400\\ Bad\\ Request:\\ KeyError:\\ 'file'",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The request does not contain the expected file field, likely because the form data is missing or the field name is incorrect.",
  "root_cause_type": "generic",
  "root_cause_zh": "请求不包含预期的文件字段，可能是因为表单数据缺失或字段名称错误。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Using request.files.get('file') returns None but doesn't raise an error, leading to AttributeError later.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Catching BadRequestKeyError and ignoring it results in silent failures.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Check if 'file' in request.files before accessing: if 'file' not in request.files:\\n    return 'No file part', 400",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Ensure the HTML form has enctype='multipart/form-data' and the input name matches.",
      "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-01-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}