{"record":{"id":"c69ad2570937bc9f","repo":"thanos-io/thanos","slug":"snappy-decode-error","errorCode":null,"errorMessage":"snappy decode error","messagePattern":"snappy decode error","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/receive/handler.go","lineNumber":835,"sourceCode":"\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\n\t}\n\n\tswitch rwVersion {\n\tcase 1:\n\t\t// NOTE: Due to zero copy ZLabels, Labels used from WriteRequests keeps memory\n\t\t// from the whole request. Ensure that we always copy those when we want to","sourceCodeStart":817,"sourceCodeEnd":853,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/handler.go#L817-L853","documentation":"Logged (and returned as HTTP 400) when s2.Decode fails on the request body of a remote-write v1 endpoint: the snappy-compressed payload is corrupt or not actually snappy/s2-encoded. The compressed bytes were read successfully; only decompression failed, so the client is at fault.","triggerScenarios":"Thrown at pkg/receive/handler.go:835 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the sender snappy-encodes the body (remote-write v1).","Check for double compression or corruption in transit.","400: do not retry the unchanged payload."],"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"}