thanos-io/thanos · error
proto: wrong wireType =
Error message
proto: wrong wireType = %d for field Timeseries
What it means
Field 5 (Timeseries) in remote-write v2 Request is a repeated message, which must be length-delimited (wire type 2). The custom Unmarshal returns this error when the bytes use another wire type for it, i.e. the stream does not conform to the schema.
Solutions
- Regenerate both sides from the same types.proto so Timeseries is field 5, wire type 2
- Validate payload with protoc --decode_raw before decoding
- Re-send the request after fixing the encoder
- Check for proxies/middleware altering request bodies
Example fix
// before: mixed schema versions senderReq.Marshal() // old schema // after: pin both services to the same generated package version require github.com/prometheus/prometheus/prompb/io/prometheus/write/v2 v0.x.y (same in sender & receiver)
Defensive patterns
Strategy: validation
Try / catch
if err := req.Unmarshal(body); err != nil { return errors.Wrap(err, "rw2 decode") } Prevention
- Ensure encoder and decoder generate from the identical .proto file
- Avoid middleware that mutates protobuf bodies
- Use round-trip tests in CI for the v2 write path
When it happens
Trigger: Unmarshal on a payload where field 5 is encoded as varint/fixed instead of length-delimited — schema mismatch between sender and receiver, byte corruption, or wrong message type decoded.
Common situations: Sender built from a different prompb version, intermediary transforming the body, corrupted transfer, or hand-written 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
- proto: Request: wiretype end group for non-group
- proto: Request: illegal tag
- proto: wrong wireType =
- proto: wrong wireType =
- proto: wrong wireType =
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/ebb3d46e6e0515a2.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/store/storepb/prompb/io/prometheus/write/v2/custom.go:75
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Symbols = append(m.Symbols, unsafe.String(unsafe.SliceData(dAtA[iNdEx:postIndex]), len(dAtA[iNdEx:postIndex])))
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Timeseries", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTypesView on GitHub (pinned to 35b8b99117)