# panic: proto: message is nil

- **ID:** `go/protobuf-nil-pointer-unmarshal`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

proto.Unmarshal or proto.Marshal was called with a nil message pointer, e.g. var m *pb.User; proto.Unmarshal(data, m). The generated methods dereference the pointer and panic.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Always allocate with m := &pb.User{} or m := new(pb.User) before Unmarshal: proto.Unmarshal(data, m).
   ```
2. **** (88% success)
   ```
   Use proto.Clone or a constructor helper that guarantees a non-nil pointer, and add a staticcheck/errcheck rule to catch nil pointer args.
   ```

## Dead Ends

- **** — Recovering hides a programming bug and returns a zero-value message that downstream logic treats as valid data. (80% fail)
- **** — The panic occurs on the call itself, before any error is returned, so the check never runs. (85% fail)
