{"record":{"id":"67627b02f9226854","repo":"thanos-io/thanos","slug":"parsing-replica-header-w","errorCode":null,"errorMessage":"parsing replica header: %w","messagePattern":"parsing replica header: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/handler.go","lineNumber":698,"sourceCode":"\tfor _, i := range wreq.Timeseries {\n\t\ths += len(i.Histograms)\n\t\tts += len(i.Samples)\n\t\tes += len(i.Exemplars)\n\t}\n\tw.Header().Set(\"X-Prometheus-Remote-Write-Samples-Written\", fmt.Sprintf(\"%d\", ts))\n\tw.Header().Set(\"X-Prometheus-Remote-Write-Histograms-Written\", fmt.Sprintf(\"%d\", hs))\n\tw.Header().Set(\"X-Prometheus-Remote-Write-Exemplars-Written\", fmt.Sprintf(\"%d\", es))\n}\n\nfunc (h *Handler) handleV1HTTP(ctx context.Context, w http.ResponseWriter, r *http.Request, wreq *prompb.WriteRequest, tLogger log.Logger, tenantHTTP string, requestLimiter requestLimiter) error {\n\tvar err error\n\n\trep := uint64(0)\n\t// If the header is empty, we assume the request is not yet replicated.\n\tif replicaRaw := r.Header.Get(h.options.ReplicaHeader); replicaRaw != \"\" {\n\t\tif rep, err = strconv.ParseUint(replicaRaw, 10, 64); err != nil {\n\t\t\thttp.Error(w, \"could not parse replica header\", http.StatusBadRequest)\n\t\t\treturn fmt.Errorf(\"parsing replica header: %w\", err)\n\t\t}\n\t}\n\n\t// Exit early if the request contained no data. We don't support metadata yet. We also cannot fail here, because\n\t// this would mean lack of forward compatibility for remote write proto.\n\tif len(wreq.Timeseries) == 0 {\n\t\t// TODO(yeya24): Handle remote write metadata.\n\t\tif len(wreq.Metadata) > 0 {\n\t\t\t// TODO(bwplotka): Do we need this error message?\n\t\t\tlevel.Debug(tLogger).Log(\"msg\", \"only metadata from client; metadata ingestion not supported; skipping\")\n\t\t\treturn nil\n\t\t}\n\t\tlevel.Debug(tLogger).Log(\"msg\", \"empty remote write request; client bug or newer remote write protocol used?; skipping\")\n\t\treturn nil\n\t}\n\n\tif !requestLimiter.AllowSeries(tenantHTTP, int64(len(wreq.Timeseries))) {\n\t\thttp.Error(w, \"too many timeseries\", http.StatusRequestEntityTooLarge)","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/handler.go#L680-L716","documentation":"The wrap text accompanying the replica-header parse failure in handleV1HTTP — the underlying strconv error is wrapped with this message (including %w) so callers see both the raw parse error and that it came from parsing the replica header.","triggerScenarios":"Thrown at pkg/receive/handler.go:698 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped strconv error for the offending value.","Fix the header to a valid unsigned integer."],"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"}