{
  "id": "go/proto-oneof-set-conflict",
  "signature": "proto: oneof field \"pb.Event.payload\" is already set with a different type",
  "signature_zh": "proto：oneof 字段 \"pb.Event.payload\" 已使用不同类型设置",
  "regex": "proto:\\ oneof\\ field\\ \"pb\\.Event\\.payload\"\\ is\\ already\\ set\\ with\\ a\\ different\\ type",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Code attempted to set two different oneof variants on the same message. A oneof can only hold one field at a time; setting a new variant clears the previous one.",
  "root_cause_type": "generic",
  "root_cause_zh": "代码尝试在同一消息上设置两个不同的 oneof 变体。oneof 一次只能持有一个字段；设置新变体会清除前一个。",
  "versions": [
    {
      "version": "google.golang.org/protobuf 1.30+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The oneof semantics still apply to the copy; only the last-set variant survives, silently dropping the first.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The message is in an inconsistent state and the wire encoding contains only one variant, causing downstream logic errors.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use the generated oneof wrapper types and set exactly one variant:\nswitch kind {\ncase \"text\":\n    msg.Payload = &pb.Event_Text{Text: value}\ncase \"blob\":\n    msg.Payload = &pb.Event_Blob{Blob: value}\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Validate with proto.CheckInitialized and inspect the active variant before sending:\nif msg.GetText() != \"\" && msg.GetBlob() != nil {\n    return status.Error(codes.InvalidArgument, \"oneof conflict\")\n}",
      "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": "2025-01-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}