{
  "id": "go/protobuf-unmarshal-invalid-wire",
  "signature": "proto: cannot parse invalid wire-format data",
  "signature_zh": "proto: 无法解析无效的 wire-format 数据",
  "regex": "proto:\\ cannot\\ parse\\ invalid\\ wire\\-format\\ data",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The bytes passed to proto.Unmarshal do not conform to protobuf wire format — often because the data is JSON, empty, truncated, or a different proto message type entirely.",
  "root_cause_type": "generic",
  "root_cause_zh": "传给 proto.Unmarshal 的字节不符合 protobuf wire format——通常因为数据是 JSON、空、被截断，或完全是另一种 proto 消息类型。",
  "versions": [
    {
      "version": "google.golang.org/protobuf 1.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Wire format is deterministic; identical bytes yield identical failure.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If bytes are binary protobuf, JSON parser fails; if JSON, the original was wrong type.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "var msg pb.User\nif json.Valid(data) {\n  err = protojson.Unmarshal(data, &msg)\n} else {\n  err = proto.Unmarshal(data, &msg)\n}\nif err != nil { return fmt.Errorf(\"decode: %w\", err) }",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "if len(data) > 0 {\n  log.Printf(\"first bytes: %x\", data[:min(len(data),16)])\n}\n// JSON starts with '{' = 0x7b; protobuf field tag usually 0x0a etc.",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}