{"record":{"id":"4a2ad39adab55b0d","repo":"multica-ai/multica","slug":"gzip-reader-w","errorCode":null,"errorMessage":"gzip reader: %w","messagePattern":"gzip reader: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/cli/update.go","lineNumber":486,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"chmod temp file: %w\", err)\n\t}\n\n\t// Replace the original binary. On Windows this moves the running executable\n\t// aside first; on Unix a plain rename over the running inode is fine.\n\tif err := replaceBinary(tmpPath, exePath); err != nil {\n\t\tos.Remove(tmpPath)\n\t\treturn \"\", fmt.Errorf(\"replace binary: %w\", err)\n\t}\n\n\treturn fmt.Sprintf(\"Downloaded %s and replaced %s\", assetName, exePath), nil\n}\n\n// extractBinaryFromTarGz reads a .tar.gz stream and returns the contents of the\n// named file entry.\nfunc extractBinaryFromTarGz(r io.Reader, name string) ([]byte, error) {\n\tgz, err := gzip.NewReader(r)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"gzip reader: %w\", err)\n\t}\n\tdefer gz.Close()\n\n\ttr := tar.NewReader(gz)\n\tfor {\n\t\thdr, err := tr.Next()\n\t\tif err == io.EOF {\n\t\t\treturn nil, fmt.Errorf(\"binary %q not found in archive\", name)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"read tar: %w\", err)\n\t\t}\n\t\t// Match the binary name (may be prefixed with a directory).\n\t\tif filepath.Base(hdr.Name) == name && hdr.Typeflag == tar.TypeReg {\n\t\t\tdata, err := io.ReadAll(tr)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"read binary: %w\", err)\n\t\t\t}","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/cli/update.go#L468-L504","documentation":"extractBinaryFromTarGz wraps the archive in gzip.NewReader first; failure returns 'gzip reader: %w' (flate.CorruptInputError or ErrHeader). Note the SHA-256 was verified against the manifest before extraction, so reaching this error with a valid checksum usually means the asset is not actually gzip data despite its name — a packaging bug rather than a corrupted transfer.","triggerScenarios":"A non-Windows asset uploaded as plain tar, zip, or compressed with another algorithm (zstd) while named .tar.gz; a release pipeline change in the compression config; a checksum manifest computed over the wrong file so a different-format archive passes verification.","commonSituations":"GoReleaser config edits (e.g. switching to zstd or disabling compression) without updating the extension logic in releaseArchiveExtension; manually re-packaged release assets that kept the old filename.","solutions":["Inspect the asset: `file multica_*.tar.gz` — it reports the real format.","Fix the release pipeline so the compression matches the file extension expected by the updater.","Re-release with consistent packaging, then retry the update.","If a custom format is intentional, extend the extractor to handle it and update asset naming."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// sniff magic bytes before extraction\nhead := make([]byte, 2)\nif _, err := io.ReadFull(bytes.NewReader(archiveData), head); err == nil {\n    if !(head[0] == 0x1f && head[1] == 0x8b) {\n        // not gzip despite .tar.gz name: reject before gzip.NewReader\n    }\n}","typeGuard":"func isGzip(data []byte) bool {\n    return len(data) >= 2 && data[0] == 0x1f && data[1] == 0x8b\n}","tryCatchPattern":"data, err := extractBinaryFromTarGz(r, \"multica\")\nif err != nil && strings.HasPrefix(err.Error(), \"gzip reader\") {\n    // packaging mismatch: asset is not gzip; check `file` on the downloaded artifact\n}","preventionTips":["Keep release compression config and file extensions consistent","Validate asset format with `file` in release CI before publishing","Don't rename artifacts to .tar.gz if they aren't gzip-compressed"],"tags":["gzip","archive","extraction","packaging"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}