thanos-io/thanos · error

missing Content-Type header

Error message

missing Content-Type header

What it means

determineRWVersion returns this when the request advertises remote-write version 2.0.0 via X-Prometheus-Remote-Write-Version but carries no Content-Type header, so the protocol version cannot be confirmed.

Solutions

  1. Send Content-Type matching the remote-write version (application/x-protobuf;proto=io.prometheus.write.v2.Request for v2).
  2. Check the sender's header construction.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/receive/handler.go:553 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/1b62ed9a6eccc8b1. Report an issue: GitHub.

Appendix: source

Thrown at pkg/receive/handler.go:553

	}
}

// retryAfterDuration returns the backoff duration for the Retry-After header,
// applying jitter when configured. A jitter of 0 returns the plain backoff.
func (h *Handler) retryAfterDuration() time.Duration {
	if h.options.RetryAfterJitter <= 0 {
		return h.options.RetryAfterBackoff
	}
	return util.DurationWithJitter(h.options.RetryAfterBackoff, h.options.RetryAfterJitter)
}

func determineRWVersion(r *http.Request) (int, error) {
	if r.Header.Get("X-Prometheus-Remote-Write-Version") != "2.0.0" {
		return 1, nil
	}
	ct := r.Header.Get("Content-Type")
	if ct == "" {
		return 0, fmt.Errorf("missing Content-Type header")
	}
	if ct == "application/x-protobuf;proto=io.prometheus.write.v2.Request" {
		return 2, nil
	}
	if ct == "application/x-protobuf" {
		return 1, nil
	}
	if ct == "application/x-protobuf;proto=prometheus.WriteRequest" {
		return 1, nil
	}
	return 0, fmt.Errorf("required headers Content-Type and/or X-Prometheus-Remote-Write-Version not found")
}

func translateV2ToV1(w writev2.Request) *prompb.WriteRequest {
	// TODO(GiedriusS): somehow ensure programmatically that all fields are set and we don't miss anything.
	out := &prompb.WriteRequest{
		Timeseries: make([]prompb.TimeSeries, 0, len(w.Timeseries)),
	}

View on GitHub (pinned to 35b8b99117)