# proto: cannot parse invalid wire-format data

- **ID:** `go/protobuf-unknown-field-error`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The received bytes are not a valid protobuf wire format, often because the client and server disagree on the message type, or because HTTP/JSON data was sent to a gRPC endpoint expecting binary protobuf.

## Version Compatibility

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

## Workarounds

1. **** (80% success)
   ```
   md, _ := metadata.FromIncomingContext(ctx)
log.Printf("content-type=%v len=%d", md.Get("content-type"), len(raw))
if err := proto.Unmarshal(raw, msg); err != nil {
    return status.Errorf(codes.InvalidArgument, "unmarshal: %v", err)
}
   ```
2. **** (90% success)
   ```
   // pin proto version in go.mod and CI check
// go.mod: require github.com/acme/protos v1.4.2
// CI: diff generated files against committed ones
   ```

## Dead Ends

- **** — The bytes are malformed, not truncated; increasing the size limit does not make invalid wire format valid. (90% fail)
- **** — The bytes are binary protobuf, not JSON; protojson will fail with a different parse error. (85% fail)
