{"record":{"id":"719e3f620165c460","repo":"github/copilot-sdk","slug":"failed-to-create-gzip-reader-w","errorCode":null,"errorMessage":"failed to create gzip reader: %w","messagePattern":"failed to create gzip reader: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":1093,"sourceCode":"func extractCLILicense(tarballPath, outputPath string) error {\n\toutputDir := filepath.Dir(outputPath)\n\tif outputDir == \"\" {\n\t\toutputDir = \".\"\n\t}\n\tlicensePath := licensePathForOutput(outputPath)\n\tif _, err := os.Stat(licensePath); err == nil {\n\t\treturn nil\n\t}\n\n\tsource, err := os.Open(tarballPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open release package: %w\", err)\n\t}\n\tdefer source.Close()\n\n\tgzReader, err := gzip.NewReader(source)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create gzip reader: %w\", err)\n\t}\n\tdefer gzReader.Close()\n\n\ttarReader := tar.NewReader(gzReader)\n\tfor {\n\t\theader, err := tarReader.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(\"failed to read tar: %w\", err)\n\t\t}\n\t\tswitch header.Name {\n\t\tcase \"package/LICENSE.md\", \"package/LICENSE\":\n\t\t\tlicenseName := filepath.Base(licensePath)\n\t\t\tif err := extractFileFromTarballStream(tarReader, outputDir, licenseName, os.FileMode(header.Mode)); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to write license: %w\", err)\n\t\t\t}","sourceCodeStart":1075,"sourceCodeEnd":1111,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L1075-L1111","documentation":"The release package is a gzipped tar; extractCLILicense wraps the file in gzip.NewReader to stream it. If the gzip header cannot be read, this error wraps the failure. It means the file at tarballPath is not valid gzip data (corrupt, truncated, or not actually a .tar.gz).","triggerScenarios":"gzip.NewReader(source) returns non-nil — unexpected EOF/gzip invalid header, because the tarball is truncated, corrupted on disk, or an HTML error page was saved instead of the archive.","commonSituations":"Earlier download silently wrote an error page (proxy portal) instead of the asset; tarball truncated by disk-full; file corrupted by a later writer; wrong file passed as tarballPath.","solutions":["Verify the file is a real gzip archive (file <tarball> or gzip -t).","Re-download the release tarball; discard the corrupt copy.","Check for proxy/VPN interference that could substitute HTML for the asset.","Confirm checksum verification ran (buildBundle does) and the correct tarballPath was passed."],"exampleFix":"// before: accepting any downloaded file without sanity check\n// after: verify gzip magic before extraction\nhead := make([]byte, 2)\nf, _ := os.Open(tarballPath)\nio.ReadFull(f, head)\nf.Close()\nif head[0] != 0x1f || head[1] != 0x8b {\n    return fmt.Errorf(\"tarball %s is not gzip data; re-download\", tarballPath)\n}","handlingStrategy":"validation","validationCode":"// confirm gzip magic before treating the file as a release package\nf, err := os.Open(tarballPath)\nif err != nil { return err }\ndefer f.Close()\nmagic := make([]byte, 2)\nif _, err := io.ReadFull(f, magic); err != nil || magic[0] != 0x1f || magic[1] != 0x8b {\n    return fmt.Errorf(\"%s is not a gzip archive\", tarballPath)\n}","typeGuard":null,"tryCatchPattern":"if err := buildBundle(...); err != nil {\n    if strings.Contains(err.Error(), \"failed to create gzip reader\") {\n        purgeCache(); reDownload(); return retryBuild()\n    }\n    return err\n}","preventionTips":["Verify checksums before reusing any cached tarball.","Detect proxy portals that substitute HTML for asset downloads.","Check `gzip -t` integrity of cached archives periodically.","Never truncate tarballs by writing to low-space disks."],"tags":["gzip","corruption","tarball","go","extraction"],"backgroundTag":"invalid-json-response","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}