{
  "id": "go/grpc-proto-marshal-error",
  "signature": "error: proto: cannot marshal, message is nil",
  "signature_zh": "错误：proto：无法序列化，消息为 nil",
  "regex": "error:\\ proto:\\ cannot\\ marshal,\\ message\\ is\\ nil",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Attempting to marshal a nil protobuf message into bytes, which is not allowed in protobuf.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试将 nil protobuf 消息序列化为字节，这在 protobuf 中是不允许的。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Use a zero-value message instead of nil",
      "why_fails": "A zero-value message still marshals to empty bytes, but if the message is nil, it will panic or error.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Check for nil but continue with empty bytes",
      "why_fails": "You need to handle the nil case explicitly, otherwise the error propagates.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Initialize the message before marshaling",
      "success_rate": 0.99,
      "how": "msg := &MyMessage{}\nb, err := proto.Marshal(msg)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use proto.MarshalOptions with deterministic output",
      "success_rate": 0.98,
      "how": "b, err := proto.MarshalOptions{}.Marshal(msg)",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}