go
runtime_error
ai_generated
true
rpc error: code = Unknown desc = runtime error: invalid memory address or nil pointer dereference
ID: go/grpc-unknown-non-status-error
80%Fix Rate
88%Confidence
0Evidence
2025-04-18First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.0+ | active | — | — | — |
Root Cause
The server handler panicked. gRPC recovers the panic and returns Unknown, but the panic message leaks into the error description. The real cause is a nil pointer dereference in the handler.
generic中文
服务端处理程序发生 panic。gRPC 恢复 panic 并返回 Unknown,但 panic 消息泄漏到错误描述中。真正的根因是处理程序中的空指针解引用。
Workarounds
-
90% success
func recovery(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { defer func() { if r := recover(); r != nil { log.Printf("panic in %s: %v\n%s", info.FullMethod, r, debug.Stack()) } }() return handler(ctx, req) } -
95% success
if req == nil || req.User == nil { return nil, status.Error(codes.InvalidArgument, "user is required") }
Dead Ends
Common approaches that don't work:
-
90% fail
The server will panic again for the same input; retries just amplify load and log noise
-
95% fail
The panic happened on the server; client-side recover cannot catch it