{"record":{"id":"3e88304e42aa797d","repo":"thanos-io/thanos","slug":"required-headers-content-type-and-or-x-prometheus","errorCode":null,"errorMessage":"required headers Content-Type and/or X-Prometheus-Remote-Write-Version not found","messagePattern":"required headers Content-Type and/or X-Prometheus-Remote-Write-Version not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/handler.go","lineNumber":564,"sourceCode":"\nfunc determineRWVersion(r *http.Request) (int, error) {\n\tif r.Header.Get(\"X-Prometheus-Remote-Write-Version\") != \"2.0.0\" {\n\t\treturn 1, nil\n\t}\n\tct := r.Header.Get(\"Content-Type\")\n\tif ct == \"\" {\n\t\treturn 0, fmt.Errorf(\"missing Content-Type header\")\n\t}\n\tif ct == \"application/x-protobuf;proto=io.prometheus.write.v2.Request\" {\n\t\treturn 2, nil\n\t}\n\tif ct == \"application/x-protobuf\" {\n\t\treturn 1, nil\n\t}\n\tif ct == \"application/x-protobuf;proto=prometheus.WriteRequest\" {\n\t\treturn 1, nil\n\t}\n\treturn 0, fmt.Errorf(\"required headers Content-Type and/or X-Prometheus-Remote-Write-Version not found\")\n}\n\nfunc translateV2ToV1(w writev2.Request) *prompb.WriteRequest {\n\t// TODO(GiedriusS): somehow ensure programmatically that all fields are set and we don't miss anything.\n\tout := &prompb.WriteRequest{\n\t\tTimeseries: make([]prompb.TimeSeries, 0, len(w.Timeseries)),\n\t}\n\n\tfor _, t := range w.Timeseries {\n\t\tv1Ts := prompb.TimeSeries{}\n\n\t\tv1Ts.Labels = make([]labelpb.ZLabel, 0, len(t.LabelsRefs)/2)\n\t\tfor i := 0; i+1 < len(t.LabelsRefs); i += 2 {\n\t\t\tv1Ts.Labels = append(v1Ts.Labels, labelpb.ZLabel{\n\t\t\t\tName:  w.Symbols[t.LabelsRefs[i]],\n\t\t\t\tValue: w.Symbols[t.LabelsRefs[i+1]],\n\t\t\t})\n\t\t}","sourceCodeStart":546,"sourceCodeEnd":582,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/handler.go#L546-L582","documentation":"The fall-through error of determineRWVersion: the remote-write request declares version 2.0.0 via X-Prometheus-Remote-Write-Version but its Content-Type matches none of the accepted protobuf content types (v2 proto, plain x-protobuf, or v1 proto), or the header/content-type combination is otherwise unrecognized. The handler cannot decide which wire format to decode and rejects the write.","triggerScenarios":"Thrown at pkg/receive/handler.go:564 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a supported Content-Type (application/x-protobuf with a known proto).","Check the remote-write client version and headers."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}