# proto: required field "pb.YourMessage.id" not set

- **ID:** `go/protobuf-marshal-required-field-missing`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The protobuf message has a required field (proto2) that was not set before marshaling.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   msg := &pb.YourMessage{
    Id: proto.String("some-id"),
    // set other required fields
}
data, err := proto.Marshal(msg)
if err != nil { log.Fatal(err) }
   ```
2. **** (90% success)
   ```
   if err := proto.CheckInitialized(msg); err != nil {
    log.Fatalf("message not initialized: %v", err)
}
data, err := proto.Marshal(msg)
   ```

## Dead Ends

- **** — Changing the proto definition may break compatibility with other services and requires regeneration. (70% fail)
- **** — Migrating to proto3 is a significant change and may not be feasible for existing systems. (60% fail)
