# panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV]

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

## Root Cause

Accessing a protobuf oneof field without checking if it is set, leading to nil pointer dereference.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |

## Workarounds

1. **Check if oneof field is non-nil before type assertion.** (98% success)
   ```
   if v := msg.GetPayload(); v != nil {
    switch x := v.(type) {
    case *pb.Payload_Text:
        fmt.Println(x.Text)
    }
}
   ```
2. **Use proto.GetField to safely retrieve oneof values.** (85% success)
   ```
   import "google.golang.org/protobuf/proto"
field := proto.GetField(msg, "payload")
   ```

## Dead Ends

- **Use a type switch without nil check.** — Oneof interface can be nil; type switch panics. (95% fail)
- **Assume the oneof is always populated.** — Unmarshal may leave it nil if field is absent. (90% fail)
