{
  "id": "go/proto-marshal-invalid-wire-type",
  "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 being unmarshaled are not valid protobuf wire format — typically caused by sending JSON, gzip-compressed payloads, or a message of a different schema over the wire.",
  "root_cause_type": "generic",
  "root_cause_zh": "被反序列化的字节不是有效的 protobuf wire format —— 通常是因为发送了 JSON、gzip 压缩载荷或使用了不同 schema 的消息。",
  "versions": [
    {
      "version": "google.golang.org/protobuf v1.31+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Unmarshal is deterministic; invalid wire bytes always fail at the same offset.",
      "fail_rate": 0.99,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Doesn't fix the underlying wire corruption; just moves the failure deeper.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "if err := proto.Unmarshal(data, msg); err != nil {\n    log.Printf(\"unmarshal failed: %v, first bytes: % x\", err, data[:min(32, len(data))])\n    return err\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.86,
      "how": "// client\nconn, _ := grpc.NewClient(addr,\n    grpc.WithDefaultCallOptions(grpc.ForceCodec(proto.Marshaler{})),\n)\n// server: verify incoming Content-Type header\nmd, _ := metadata.FromIncomingContext(ctx)\nlog.Printf(\"content-type: %v\", md[\"content-type\"])",
      "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-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}