# panic: runtime error: invalid memory address or nil pointer dereference

- **ID:** `go/grpc-unary-interceptor-nil-response`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.x | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   Ensure handlers always return a non-nil message with nil error: return &pb.UserResponse{...}, nil; and validate in interceptors that reply != nil before returning.
   ```
2. **** (85% success)
   ```
   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).
   ```

## Dead Ends

- **** — Recovering hides the nil reply and returns a zero-value to the caller, which then processes garbage. (80% fail)
- **** — The panic may occur inside the server handler or interceptor chain before the response is sent. (75% fail)
