# proto: message field "User.name" is required but not set

- **ID:** `go/protobuf-message-field-not-set`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

proto2 required fields (or proto3 with field presence expectations) were not populated before marshaling. Proto3 removed required, so this often comes from proto2 files or validation libraries like protoc-gen-validate.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   u := &pb.User{Name: "alice", Email: "a@example.com"}
if err := proto.CheckInitialized(u); err != nil {
    return fmt.Errorf("invalid user: %w", err)
}
b, err := proto.Marshal(u)
   ```
2. **** (90% success)
   ```
   // user.proto: string name = 1 [(validate.rules).string = {min_len: 1}];
if err := u.Validate(); err != nil {
    return status.Errorf(codes.InvalidArgument, "%v", err)
}
   ```

## Dead Ends

- **** — AllowPartial only suppresses the marshal error; it still emits a message missing the required field, which the peer will reject on unmarshal. (85% fail)
- **** — Removing required breaks backward compatibility and shifts the failure to runtime nil dereferences downstream. (60% fail)
