# proto: cannot parse invalid wire-format data: illegal tag 0 (wire type 0)

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

## Root Cause

The protobuf binary data is corrupted or not in the expected format. This can happen when the data is truncated, sent over a non-binary channel, or when the wrong message type is used for unmarshaling.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   // Before unmarshaling, check data length and source
if len(data) == 0 {
    return errors.New("empty data")
}
var msg YourMessage
if err := proto.Unmarshal(data, &msg); err != nil {
    log.Printf("unmarshal failed: %v, data: %x", err, data)
    return err
}
   ```
2. **** (85% success)
   ```
   // If data is JSON, use protojson
var msg YourMessage
if err := protojson.Unmarshal(jsonData, &msg); err != nil {
    log.Fatalf("protojson unmarshal failed: %v", err)
}
   ```

## Dead Ends

- **** — The error is not about buffer size but about invalid data structure; increasing buffer won't fix corrupted data. (95% fail)
- **** — This leads to silent data corruption and unpredictable behavior downstream. (90% fail)
