# proto: oneof field "pb.Event.payload" is already set with a different type

- **ID:** `go/proto-oneof-set-conflict`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Code attempted to set two different oneof variants on the same message. A oneof can only hold one field at a time; setting a new variant clears the previous one.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Use the generated oneof wrapper types and set exactly one variant:
switch kind {
case "text":
    msg.Payload = &pb.Event_Text{Text: value}
case "blob":
    msg.Payload = &pb.Event_Blob{Blob: value}
}
   ```
2. **** (90% success)
   ```
   Validate with proto.CheckInitialized and inspect the active variant before sending:
if msg.GetText() != "" && msg.GetBlob() != nil {
    return status.Error(codes.InvalidArgument, "oneof conflict")
}
   ```

## Dead Ends

- **** — The oneof semantics still apply to the copy; only the last-set variant survives, silently dropping the first. (85% fail)
- **** — The message is in an inconsistent state and the wire encoding contains only one variant, causing downstream logic errors. (90% fail)
