# Protobuf deserialization silently drops unknown oneof fields causing data loss

- **ID:** `data/protobuf-oneof-unknown-field`
- **Domain:** data
- **Category:** protocol_error
- **Error Code:** `No explicit error; silent data corruption`
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

When a Protobuf message with a oneof field is deserialized by an older version that doesn't know the new oneof variant, the entire oneof is set to None, losing all other known fields in that oneof.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Protocol Buffers 3.21.0 | active | — | — |
| gRPC 1.58.0 | active | — | — |

## Workarounds

1. **Add a catch-all 'bytes unknown_oneof' field to the message to preserve raw bytes of unknown oneof variants, then manually parse.** (85% success)
   ```
   Add a catch-all 'bytes unknown_oneof' field to the message to preserve raw bytes of unknown oneof variants, then manually parse.
   ```
2. **Ensure all consumers are updated to the latest proto definition before deploying new oneof variants.** (90% success)
   ```
   Ensure all consumers are updated to the latest proto definition before deploying new oneof variants.
   ```

## Dead Ends

- **Adding a new field outside the oneof to carry the new variant** — This changes the message structure and may cause confusion, and the oneof still gets cleared on unknown variants. (50% fail)
- **Using 'optional' keyword for oneof fields** — The 'optional' keyword does not prevent the oneof from being cleared when an unknown variant is encountered. (70% fail)
