{
  "id": "go/proto-nil-message-marshal",
  "signature": "panic: proto: Marshal called with nil",
  "signature_zh": "panic：proto：Marshal 被以 nil 调用",
  "regex": "panic:\\ proto:\\ Marshal\\ called\\ with\\ nil",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "proto.Marshal was passed a nil pointer, often from a handler returning (nil, nil) or an uninitialized nested field.",
  "root_cause_type": "generic",
  "root_cause_zh": "proto.Marshal 接收到 nil 指针，通常源于处理函数返回 (nil, nil) 或未初始化的嵌套字段。",
  "versions": [
    {
      "version": "google.golang.org/protobuf 1.31+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Masks the bug; nil responses keep leaking to clients as empty messages.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changes the API contract; clients can no longer distinguish 'no result' from 'empty result'.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Always return a non-nil message or an explicit status error:\nif user == nil {\n  return nil, status.Error(codes.NotFound, \"user not found\")\n}\nreturn &pb.GetUserResponse{User: user}, nil",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Add a unit test that asserts every handler returns either a non-nil message or a non-nil error.",
      "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-03-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}