# proto: field "pb.Config.Timeout" is already set in oneof "pb.Config.value"

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

## Root Cause

A oneof field was assigned twice on the same message. In google.golang.org/protobuf, setting a oneof field clears the others but setting the same field via reflection twice can trigger this in some generated code paths.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Use the generated oneof wrapper types explicitly:
cfg := &pb.Config{}
cfg.Value = &pb.Config_Timeout{Timeout: 5 * time.Second}
   ```
2. **** (85% success)
   ```
   Check which variant is set before assigning:
if _, ok := cfg.Value.(*pb.Config_Timeout); !ok {
    cfg.Value = &pb.Config_Timeout{Timeout: d}
}
   ```

## Dead Ends

- **** — proto.Reset clears all fields, losing unrelated data you already populated. (70% fail)
- **** — The panic leaves the message in an inconsistent state; subsequent marshaling may produce corrupt output. (80% fail)
