{"record":{"id":"d3c68f783bc5afab","repo":"JuliusBrussee/caveman","slug":"gzip-reader-w","errorCode":null,"errorMessage":"gzip reader: %w","messagePattern":"gzip reader: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/objectstore/compress.go","lineNumber":79,"sourceCode":"\n// DecompressLimit reverses Compress while refusing to produce more than\n// maxBytes of plaintext. The limit is applied while decoding gzip and through\n// zstd's decoder memory bound, so highly-compressible hostile payloads cannot\n// first allocate their full expanded size and only then be rejected.\nfunc DecompressLimit(codec string, data []byte, maxBytes int64) ([]byte, error) {\n\tif maxBytes < 0 || maxBytes > DefaultMaxDecompressedBytes {\n\t\treturn nil, fmt.Errorf(\"invalid decompression limit %d\", maxBytes)\n\t}\n\tswitch codec {\n\tcase CompressionNone, \"\":\n\t\tif int64(len(data)) > maxBytes {\n\t\t\treturn nil, ErrDecompressedTooLarge\n\t\t}\n\t\treturn data, nil\n\tcase CompressionGzip:\n\t\tzr, err := gzip.NewReader(bytes.NewReader(data))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"gzip reader: %w\", err)\n\t\t}\n\t\tdefer zr.Close()\n\t\tout, err := io.ReadAll(io.LimitReader(zr, maxBytes+1))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"gzip read: %w\", err)\n\t\t}\n\t\tif int64(len(out)) > maxBytes {\n\t\t\treturn nil, ErrDecompressedTooLarge\n\t\t}\n\t\treturn out, nil\n\tcase CompressionZstd:\n\t\t// Zstd's smallest legal window is 1 KiB. Keep that parser minimum for\n\t\t// tiny valid payloads, then independently enforce the exact byte limit.\n\t\tmemoryLimit := uint64(maxBytes)\n\t\tif memoryLimit < zstd.MinWindowSize {\n\t\t\tmemoryLimit = zstd.MinWindowSize\n\t\t}\n\t\tzr, err := zstd.NewReader(nil,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/shared/platform/objectstore/compress.go#L61-L97","documentation":"Error \"gzip reader: %w\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at shared/platform/objectstore/compress.go:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The gzip stream is invalid; provide valid gzip data."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}