{
  "id": "go/proto-nil-message-panic",
  "signature": "panic: runtime error: invalid memory address or nil pointer dereference",
  "signature_zh": "panic：运行时错误：无效的内存地址或空指针解引用",
  "regex": "panic:\\ runtime\\ error:\\ invalid\\ memory\\ address\\ or\\ nil\\ pointer\\ dereference",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A nil *Message pointer was passed to proto.Marshal, proto.Clone, or a generated getter was called on a nil receiver that dereferences a map field.",
  "root_cause_type": "generic",
  "root_cause_zh": "向 proto.Marshal、proto.Clone 传递了 nil *Message 指针，或在 nil 接收者上调用了会解引用 map 字段的生成 getter。",
  "versions": [
    {
      "version": "google.golang.org/protobuf v1.28+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Masks the nil bug; the same nil pointer will surface elsewhere or cause silent data loss.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "AllowPartial only affects required-field validation, not nil pointer dereferences.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "if msg == nil {\n    return nil, status.Error(codes.InvalidArgument, \"nil message\")\n}\ndata, err := proto.Marshal(msg)\nif err != nil { return nil, err }",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "clone := proto.Clone(msg) // returns nil if msg is nil\nif clone == nil {\n    return nil, errors.New(\"nil proto message\")\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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}