{
  "id": "python/flask-request-form-data-missing",
  "signature": "KeyError: 'username'",
  "signature_zh": "键错误：'username'",
  "regex": "KeyError:\\ 'username'",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Flask 请求的表单数据中缺少 'username' 字段",
  "root_cause_type": "generic",
  "root_cause_zh": "Flask 请求的表单数据中缺少 'username' 字段",
  "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": "使用 request.args.get 而非 request.form.get",
      "why_fails": "表单数据在 request.form 中，不在查询参数中",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "在表单中硬编码默认值但不验证",
      "why_fails": "可能接受无效数据",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "使用 get 方法并提供默认值",
      "success_rate": 0.95,
      "how": "username = request.form.get('username', '')",
      "condition": "",
      "sources": []
    },
    {
      "action": "检查字段是否存在并返回错误",
      "success_rate": 0.9,
      "how": "if 'username' not in request.form:\n    return '缺少用户名', 400",
      "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-10-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}