# panic: proto: Marshal called with nil

- **ID:** `go/proto-marshal-nil-message`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

google.golang.org/protobuf Marshal/Unmarshal was called with a nil proto.Message, typically a nil pointer returned from a function that was supposed to build a request.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| google.golang.org/protobuf 1.28+ | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Guard against nil before marshaling:
if req == nil {
    return status.Error(codes.InvalidArgument, "request is nil")
}
_ = req.ProtoReflect().IsValid()
   ```
2. **** (90% success)
   ```
   Return value types instead of pointers from builders, or always allocate:
req := &pb.GetUserRequest{}
if userID != "" { req.Id = userID }
   ```

## Dead Ends

- **** — Recovering hides the nil bug; the request is still malformed and downstream calls fail silently. (80% fail)
- **** — proto.Clone(nil) also panics with the same message. (90% fail)
