thanos-io/thanos · error

proto: wrong wireType =

Error message

proto: wrong wireType = %d for field Hash

What it means

This error comes from the hand-written gogo/golang proto Unmarshal path for a storepb message. It is thrown when the wire type of field 3 (Hash) on the wire does not match the declared type (varint, wireType 0). It means the encoded bytes being decoded are not valid protobuf for this message schema.

Solutions

  1. Regenerate/align storepb protobuf definitions so both encoder and decoder use the same schema version
  2. Verify the byte source: confirm the client actually serializes a storepb SeriesResponse/Chunk and not another message type
  3. Re-encode the payload with the current proto library and retry
  4. If data comes from disk/network, checksum and re-transfer the payload

Example fix

// before: decoding arbitrary bytes as storepb
var resp storepb.SeriesResponse
resp.Unmarshal(rawBytes)
// after: ensure the payload is produced by matching storepb types
respBytes, err := expectedResp.Marshal()
if err != nil { return err }
err = resp.Unmarshal(respBytes)
Defensive patterns

Strategy: validation

Validate before calling

if len(payload) == 0 { return errors.New("empty storepb payload") }

Try / catch

if err := resp.Unmarshal(b); err != nil { return fmt.Errorf("storepb decode failed: %w", err) }

Prevention

When it happens

Trigger: Calling Unmarshal (directly or via XXX_Unmarshal) on bytes where field 3 is encoded with a non-varint wire type — e.g. the payload was produced by a different/older schema, truncated, corrupted, or misinterpreted as this message type.

Common situations: Version skew between Thanos components (one side has a different storepb contract), sending raw bytes of one message type to a storepb endpoint, corrupted network payloads, or manually crafted/canned test data with wrong encoding.

Understand the failure class

Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/d6d89c8ea50ed874. Report an issue: GitHub.

Appendix: source

Thrown at pkg/store/storepb/custom.go:666

				if b < 0x80 {
					break
				}
			}
			if byteLen < 0 {
				return ErrInvalidLengthTypes
			}
			postIndex := iNdEx + byteLen
			if postIndex < 0 {
				return ErrInvalidLengthTypes
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			m.Data = dAtA[iNdEx:postIndex]
			iNdEx = postIndex
		case 3:
			if wireType != 0 {
				return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
			}
			m.Hash = 0
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				m.Hash |= uint64(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
		default:
			iNdEx = preIndex

View on GitHub (pinned to 35b8b99117)