{"record":{"id":"6cc64973c882d2da","repo":"thanos-io/thanos","slug":"read-compressed-request-body","errorCode":null,"errorMessage":"read compressed request body","messagePattern":"read compressed request body","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"pkg/receive/handler.go","lineNumber":829,"sourceCode":"\t\treturn\n\t}\n\n\trequestLimiter := h.Limiter.RequestLimiter()\n\t// io.ReadAll dynamically adjust the byte slice for read data, starting from 512B.\n\t// Since this is receive hot path, grow upfront saving allocations and CPU time.\n\tcompressed := bytes.Buffer{}\n\tif r.ContentLength >= 0 {\n\t\tif !requestLimiter.AllowSizeBytes(tenantHTTP, r.ContentLength) {\n\t\t\thttp.Error(w, \"write request too large\", http.StatusRequestEntityTooLarge)\n\t\t\treturn\n\t\t}\n\t\tcompressed.Grow(int(r.ContentLength))\n\t} else {\n\t\tcompressed.Grow(512)\n\t}\n\t_, err = io.Copy(&compressed, r.Body)\n\tif err != nil {\n\t\thttp.Error(w, errors.Wrap(err, \"read compressed request body\").Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\treqBuf, err := s2.Decode(nil, compressed.Bytes())\n\tif err != nil {\n\t\tlevel.Error(tLogger).Log(\"msg\", \"snappy decode error\", \"err\", err)\n\t\thttp.Error(w, errors.Wrap(err, \"snappy decode error\").Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif !requestLimiter.AllowSizeBytes(tenantHTTP, int64(len(reqBuf))) {\n\t\thttp.Error(w, \"write request too large\", http.StatusRequestEntityTooLarge)\n\t\treturn\n\t}\n\n\trwVersion, err := determineRWVersion(r)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn","sourceCodeStart":811,"sourceCodeEnd":847,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/handler.go#L811-L847","documentation":"io.Copy from r.Body into the compressed buffer failed while reading the snappy-compressed request body (client disconnect or network error mid-upload), so the handler responds 500 and the request is lost.","triggerScenarios":"Thrown at pkg/receive/handler.go:829 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request; the connection broke mid-transfer.","Check client and network stability.","Verify no proxy times out long uploads."],"exampleFix":null,"handlingStrategy":"retry","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"}