{
  "id": "go/proto-oneof-set-twice",
  "signature": "proto: field \"pb.Config.Timeout\" is already set in oneof \"pb.Config.value\"",
  "signature_zh": "proto：字段 \"pb.Config.Timeout\" 已在 oneof \"pb.Config.value\" 中设置",
  "regex": "proto:\\ field\\ \"pb\\.Config\\.Timeout\"\\ is\\ already\\ set\\ in\\ oneof\\ \"pb\\.Config\\.value\"",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A oneof field was assigned twice on the same message. In google.golang.org/protobuf, setting a oneof field clears the others but setting the same field via reflection twice can trigger this in some generated code paths.",
  "root_cause_type": "generic",
  "root_cause_zh": "同一消息上的 oneof 字段被赋值两次。在 google.golang.org/protobuf 中，设置 oneof 字段会清除其他字段，但通过反射对同一字段设置两次可能在某些生成代码路径中触发此错误。",
  "versions": [
    {
      "version": "google.golang.org/protobuf 1.28+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "proto.Reset clears all fields, losing unrelated data you already populated.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The panic leaves the message in an inconsistent state; subsequent marshaling may produce corrupt output.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use the generated oneof wrapper types explicitly:\ncfg := &pb.Config{}\ncfg.Value = &pb.Config_Timeout{Timeout: 5 * time.Second}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Check which variant is set before assigning:\nif _, ok := cfg.Value.(*pb.Config_Timeout); !ok {\n    cfg.Value = &pb.Config_Timeout{Timeout: d}\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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}