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

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

## Root Cause

Accessing a submessage field of a proto message that was never set returns nil. Calling a getter is safe, but direct field access on a nil submessage panics.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   // BAD: msg.Address.City
// GOOD:
city := msg.GetAddress().GetCity()
if city == "" { city = "unknown" }
   ```
2. **** (93% success)
   ```
   if addr := msg.GetAddress(); addr != nil {
    fmt.Println(addr.Street)
} else {
    fmt.Println("address not set")
}
   ```

## Dead Ends

- **** — recover hides the bug and leaves the RPC handler in an inconsistent state; the underlying nil field is still unset. (80% fail)
- **** — The peer or the server-side merge may still leave optional submessages unset, so the panic returns whenever the message is absent. (65% fail)
