{
  "id": "python/flask-unicode-decode-error",
  "signature": "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte",
  "signature_zh": "UnicodeDecodeError: 'utf-8' 编解码器无法解码位置 0 的字节 0xff：无效起始字节。",
  "regex": "UnicodeDecodeError:\\ 'utf\\-8'\\ codec\\ can't\\ decode\\ byte\\ 0xff\\ in\\ position\\ 0:\\ invalid\\ start\\ byte",
  "domain": "python",
  "category": "encoding_error",
  "subcategory": null,
  "root_cause": "`request.data.decode()` or reading a form field assumed UTF-8 but the client sent another encoding (e.g., Windows-1252 or binary).",
  "root_cause_type": "generic",
  "root_cause_zh": "`request.data.decode()` 或读取表单字段时假设 UTF-8，但客户端发送了其他编码（如 Windows-1252 或二进制）。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Silently drops bytes; corrupts data.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Output config, not input decoding.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "charset = request.mimetype_params.get('charset', 'utf-8')\ntext = request.data.decode(charset)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "try:\n    text = request.data.decode('utf-8')\nexcept UnicodeDecodeError:\n    return jsonify(error='invalid encoding'), 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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-28",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}