{"record":{"id":"cdead845249efb71","repo":"plandex-ai/plandex","slug":"failed-to-create-gzip-reader-w","errorCode":null,"errorMessage":"failed to create gzip reader: %w","messagePattern":"failed to create gzip reader: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/upgrade.go","lineNumber":131,"sourceCode":"\t\treturn fmt.Errorf(\"failed to create temporary file: %w\", err)\n\t}\n\tdefer os.Remove(tempFile.Name()) // Clean up file afterwards\n\n\t// Copy the response body to the temporary file\n\t_, err = io.Copy(tempFile, resp.Body)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to save the downloaded archive: %w\", err)\n\t}\n\n\t_, err = tempFile.Seek(0, 0)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to seek in temporary file: %w\", err)\n\t}\n\n\t// Now, extract the binary from the tempFile\n\tgzr, err := gzip.NewReader(tempFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create gzip reader: %w\", err)\n\t}\n\tdefer gzr.Close()\n\n\ttarReader := tar.NewReader(gzr)\n\tfor {\n\t\theader, err := tarReader.Next()\n\t\tif err == io.EOF {\n\t\t\tbreak // End of archive\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to read tar header: %w\", err)\n\t\t}\n\n\t\t// Check if the current file is the binary\n\t\tif header.Typeflag == tar.TypeReg && (header.Name == \"plandex\" || header.Name == \"plandex.exe\") {\n\t\t\terr = update.Apply(tarReader, update.Options{})\n\t\t\tif err != nil {\n\t\t\t\tif errors.Is(err, fs.ErrPermission) {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/upgrade.go#L113-L149","documentation":"doUpgrade wraps the downloaded archive in a gzip.NewReader to decompress the tar.gz release. If the stream's first bytes are not valid gzip data, it returns 'failed to create gzip reader: %w'. This almost always means the downloaded file is not the expected release tarball.","triggerScenarios":"gzip.NewReader(tempFile) fails because the downloaded content is not gzip — a 404/HTML error page was saved instead of the archive, the download was truncated, or a proxy returned an intercepted response.","commonSituations":"Release tag typo/version not published so GitHub returns a 404 page; corporate proxy injecting an HTML block page; partial download from a dropped connection; wrong GOOS/GOARCH asset name.","solutions":["Check resp.StatusCode == 200 before saving the body (404/HTML pages cause this).","Verify the release tag cli/v<version> and asset plandex_<version>_<GOOS>_<GOARCH>.tar.gz exist on GitHub.","Clear/adjust proxy settings that may intercept the download.","Retry the download to rule out truncation."],"exampleFix":"// before (no status check; error page saved as tar.gz)\nresp, err := http.Get(downloadURL)\nif err != nil {\n\treturn fmt.Errorf(\"failed to download the update: %w\", err)\n}\ndefer resp.Body.Close()\n// after\nif resp.StatusCode != http.StatusOK {\n\treturn fmt.Errorf(\"unexpected download status: %s\", resp.Status)\n}","handlingStrategy":"validation","validationCode":"// before decompressing, check HTTP status and magic bytes\nif resp.StatusCode != http.StatusOK {\n\treturn fmt.Errorf(\"unexpected status: %s\", resp.Status)\n}\nhead := make([]byte, 2)\nif _, err := io.ReadFull(tempFile, head); err != nil {\n\treturn fmt.Errorf(\"archive too short: %w\", err)\n}\nif head[0] != 0x1f || head[1] != 0x8b {\n\treturn fmt.Errorf(\"not a gzip file\")\n}\ntempFile.Seek(0, io.SeekStart)","typeGuard":null,"tryCatchPattern":"gzr, err := gzip.NewReader(tempFile)\nif err != nil {\n\treturn fmt.Errorf(\"failed to create gzip reader: %w — downloaded file may not be a valid release archive\", err)\n}","preventionTips":["Always verify HTTP 200 before saving the body","Validate the gzip magic bytes (1f 8b) before parsing","Confirm the release asset name matches GOOS/GOARCH","Beware proxies injecting HTML into downloads"],"tags":["gzip","archive","corrupt-download","go"],"backgroundTag":"invalid-gzip-data","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}