{
  "id": "go/grpc-unary-interceptor-nil-response",
  "signature": "panic: runtime error: invalid memory address or nil pointer dereference",
  "signature_zh": "panic: 运行时错误：无效的内存地址或 nil 指针解引用",
  "regex": "panic:\\ runtime\\ error:\\ invalid\\ memory\\ address\\ or\\ nil\\ pointer\\ dereference",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A unary interceptor returned nil error but left the reply message nil, or the handler returned a nil response with a nil error. The caller then dereferences the nil reply.",
  "root_cause_type": "generic",
  "root_cause_zh": "一元拦截器返回了 nil 错误但将回复消息留为 nil，或处理函数返回了 nil 响应和 nil 错误。调用方随后解引用该 nil 回复。",
  "versions": [
    {
      "version": "1.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Recovering hides the nil reply and returns a zero-value to the caller, which then processes garbage.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The panic may occur inside the server handler or interceptor chain before the response is sent.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "Ensure handlers always return a non-nil message with nil error: return &pb.UserResponse{...}, nil; and validate in interceptors that reply != nil before returning.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Use protoc-gen-validate or manual checks to guarantee non-nil responses, and add a unit test that asserts the handler never returns (nil, nil).",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-03-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}