{"record":{"id":"02682b11f08359ca","repo":"chenhg5/cc-connect","slug":"gzip-w","errorCode":null,"errorMessage":"gzip: %w","messagePattern":"gzip: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/update.go","lineNumber":324,"sourceCode":"\n// extractBinaryFromArchive extracts the cc-connect binary from a .tar.gz or .zip archive.\nfunc extractBinaryFromArchive(archivePath, archiveName string) (string, error) {\n\tif strings.HasSuffix(archiveName, \".zip\") {\n\t\treturn extractFromZip(archivePath)\n\t}\n\treturn extractFromTarGz(archivePath)\n}\n\nfunc extractFromTarGz(archivePath string) (string, error) {\n\tf, err := os.Open(archivePath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer f.Close()\n\n\tgz, err := gzip.NewReader(f)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"gzip: %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\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"tar: %w\", err)\n\t\t}\n\t\tif hdr.Typeflag != tar.TypeReg {\n\t\t\tcontinue\n\t\t}\n\t\tif strings.HasPrefix(hdr.Name, \"cc-connect\") {\n\t\t\ttmp, err := os.CreateTemp(\"\", \"cc-connect-update-*\")\n\t\t\tif err != nil {","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/update.go#L306-L342","documentation":"extractFromTarGz wraps errors from gzip.NewReader as \"gzip: %w\". It means the downloaded archive file could not be opened as a gzip stream — the file is not gzip-compressed (or is corrupt) at the very first bytes.","triggerScenarios":"gzip.NewReader(f) fails on the downloaded file: the file is actually an HTML error page saved as the asset (proxy served a 200 error page), the download was truncated/corrupted, wrong asset picked, or the release asset is a .zip instead of .tar.gz.","commonSituations":"Updating through a corporate proxy that substitutes HTML block pages; interrupted download leaving a partial file; picking the wrong asset (zip on Linux); asset replaced/removed on the release page; disk corruption in the temp/cache dir.","solutions":["Inspect the file with `file <archive>` or `head -c 200 <archive>` — HTML text means the download fetched an error page; fix proxy or re-download","Delete the cached/partial archive and retry the update so it re-downloads","Verify the asset name matches your platform (tar.gz for Linux/macOS, zip for Windows) and that binaryAssetName(tag) targets the right file","Verify asset checksums against the release notes before extraction"],"exampleFix":"// before\ngz, err := gzip.NewReader(f)\nif err != nil {\n    return \"\", fmt.Errorf(\"gzip: %w\", err)\n}\n// after\ngz, err := gzip.NewReader(f)\nif err != nil {\n    return \"\", fmt.Errorf(\"gzip: %w (archive corrupt or not gzip; re-download the asset)\", err)\n}","handlingStrategy":"validation","validationCode":"// validate the downloaded file is gzip before extraction:\nhead := make([]byte, 2)\nf, _ := os.Open(archivePath)\nio.ReadFull(f, head)\nf.Close()\nif head[0] != 0x1f || head[1] != 0x8b {\n    return errors.New(\"downloaded file is not gzip — proxy error page or wrong asset?\")\n}","typeGuard":null,"tryCatchPattern":"// Go: delete bad downloads and retry once\nif _, err := extractBinaryFromArchive(path); err != nil {\n    if strings.Contains(err.Error(), \"gzip:\") {\n        os.Remove(path)\n        if newPath := reDownload(assetURL); newPath != \"\" {\n            _, err = extractBinaryFromArchive(newPath)\n        }\n    }\n}","preventionTips":["Verify the asset checksum from the release notes after download","Ensure proxies bypass GitHub release downloads (assets redirect to objects.githubusercontent.com)","Match the asset to your OS/arch exactly (tar.gz vs zip)","Avoid resuming partial downloads without verifying total size"],"tags":["archive","gzip","download","update-checker","corrupt-file"],"backgroundTag":"file-open-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}