thanos-io/thanos · error

proto: Request: wiretype end group for non-group

Error message

proto: Request: wiretype end group for non-group

What it means

This is a hand-written proto Unmarshal validation for the Prometheus remote-write v2 Request. Wire type 4 is the 'end group' marker; since proto3 messages here are not groups, encountering it means the bytes are not a valid Request per the schema.

Solutions

  1. Ensure the sender uses remote-write v2 protobuf encoding (X-Prometheus-Remote-Write-Version: 2.0.0)
  2. Verify the request body was not truncated or transformed by a proxy (Content-Length vs actual bytes)
  3. Decode with the correct proto type matching the sender's schema
  4. Log and reject the payload; do not attempt lenient parsing

Example fix

// before: blindly unmarshaling any body
var req prompb.WriteV2Request
req.Unmarshal(body)
// after: check version header first
if r.Header.Get("X-Prometheus-Remote-Write-Version") != "2.0.0" { http.Error(w, "unsupported rw version", http.StatusUnsupportedMediaType); return }
err := req.Unmarshal(body)
Defensive patterns

Strategy: validation

Validate before calling

if r.Header.Get("X-Prometheus-Remote-Write-Version") != "2.0.0" { return status.Errorf(codes.InvalidArgument, "unsupported RW version") }

Try / catch

if err := req.Unmarshal(body); err != nil { http.Error(w, "malformed remote-write body", http.StatusBadRequest); return }

Prevention

When it happens

Trigger: Calling Unmarshal (via XXX_Unmarshal) on payload bytes where a field tag encodes an end-group marker — malformed, truncated-from-the-front, or non-remote-write-v2 data posted to the write v2 handler.

Common situations: A client posting remote-write v1 (or another protobuf) payload where a v2 Request is expected, corrupted request bodies in transit, or fuzzing/malicious traffic against the ingest endpoint.

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/5f2ab56492915249. Report an issue: GitHub.

Appendix: source

Thrown at pkg/store/storepb/prompb/io/prometheus/write/v2/custom.go:35

		var wire uint64
		for shift := uint(0); ; shift += 7 {
			if shift >= 64 {
				return ErrIntOverflowTypes
			}
			if iNdEx >= l {
				return io.ErrUnexpectedEOF
			}
			b := dAtA[iNdEx]
			iNdEx++
			wire |= uint64(b&0x7F) << shift
			if b < 0x80 {
				break
			}
		}
		fieldNum := int32(wire >> 3)
		wireType := int(wire & 0x7)
		if wireType == 4 {
			return fmt.Errorf("proto: Request: wiretype end group for non-group")
		}
		if fieldNum <= 0 {
			return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire)
		}
		switch fieldNum {
		case 4:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Symbols", wireType)
			}
			var stringLen uint64
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]

View on GitHub (pinned to 35b8b99117)