thanos-io/thanos · error

proto: cannot parse invalid wire-format data

Error message

proto: cannot parse invalid wire-format data

What it means

proto.Unmarshal of the v1 WriteRequest failed — the decompressed body is not valid protobuf wire format (wrong content type, corruption, or a non-snappy payload sent to the endpoint); the handler responds 400.

Solutions

  1. Verify the sender targets the correct endpoint and encoding.
  2. Check that compression/proxy layers do not alter the body.
  3. Client bug: fix serialization, do not retry as-is.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/receive/handler.go:857 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at pkg/receive/handler.go:857

	if !requestLimiter.AllowSizeBytes(tenantHTTP, int64(len(reqBuf))) {
		http.Error(w, "write request too large", http.StatusRequestEntityTooLarge)
		return
	}

	rwVersion, err := determineRWVersion(r)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	switch rwVersion {
	case 1:
		// NOTE: Due to zero copy ZLabels, Labels used from WriteRequests keeps memory
		// from the whole request. Ensure that we always copy those when we want to
		// store them for longer time.
		var wreq prompb.WriteRequest
		if err := proto.Unmarshal(reqBuf, &wreq); err != nil {
			http.Error(w, err.Error(), http.StatusBadRequest)
			return
		}
		_ = h.handleV1HTTP(ctx, w, r, &wreq, tLogger, tenantHTTP, requestLimiter)
	case 2:
		h.handleV2HTTP(ctx, w, r, reqBuf, tLogger, tenantHTTP, requestLimiter)
	default:
		panic("unsupported remote_write version")
	}
}

type requestStats struct {
	timeseries   int
	totalSamples int
}

type tenantRequestStats map[string]requestStats

func (h *Handler) handleRequest(ctx context.Context, rep uint64, data []wreqTenantTuple) (tenantRequestStats, error) {

View on GitHub (pinned to 35b8b99117)