# proto: cannot parse invalid wire-format data

- **ID:** `go/proto-unmarshal-invalid-wire-type`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The bytes handed to proto.Unmarshal do not conform to the protobuf wire format. Usually caused by passing JSON, plain text, or a truncated/concatenated buffer to a binary proto unmarshaler.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   if err := proto.Unmarshal(data, msg); err != nil {
    // if data is JSON, use:
    err = protojson.Unmarshal(data, msg)
}
   ```
2. **** (85% success)
   ```
   log.Printf("len=%d head=%x", len(data), data[:min(16,len(data))])
   ```

## Dead Ends

- **** — The buffer is deterministic; malformed bytes never become valid on retry. The error is not transient. (95% fail)
- **** — On wire-format errors the message is left in an undefined/partial state; downstream logic reads zero or garbage fields. (90% fail)
