{"record":{"id":"2054e65909987b10","repo":"plandex-ai/plandex","slug":"failed-to-save-the-downloaded-archive-w","errorCode":null,"errorMessage":"failed to save the downloaded archive: %w","messagePattern":"failed to save the downloaded archive: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/upgrade.go","lineNumber":120,"sourceCode":"\n\tdownloadURL := fmt.Sprintf(\"https://github.com/plandex-ai/plandex/releases/download/%s/plandex_%s_%s_%s.tar.gz\", escapedTag, version, runtime.GOOS, runtime.GOARCH)\n\tresp, err := http.Get(downloadURL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to download the update: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// Create a temporary file to save the downloaded archive\n\ttempFile, err := os.CreateTemp(\"\", \"*.tar.gz\")\n\tif err != nil {\n\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 {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/upgrade.go#L102-L138","documentation":"doUpgrade streams the HTTP response body into the temp file with io.Copy. If the write fails mid-transfer (disk full, I/O error) or reading the response body fails (connection reset mid-download), it returns 'failed to save the downloaded archive: %w'. Note io.Copy also surfaces read errors from resp.Body, so truncated network transfers land here too.","triggerScenarios":"io.Copy(tempFile, resp.Body) errors: out of disk space while writing the archive, interrupted network connection during the download, or storage device I/O error.","commonSituations":"Full /tmp partition on a large release download; flaky Wi-Fi dropping mid-download; proxy terminating long transfers; disk quota exceeded.","solutions":["Free disk space on the temp filesystem.","Retry the upgrade on a stable connection.","Check TMPDIR for a faster/larger filesystem and set TMPDIR accordingly.","Download the release manually and install it if the network keeps dropping."],"exampleFix":"// before (no size/status checks before copy)\n_, err = io.Copy(tempFile, resp.Body)\n// after (validate status and use a size-aware copy)\nif resp.StatusCode != http.StatusOK {\n\treturn fmt.Errorf(\"unexpected download status: %s\", resp.Status)\n}\nif _, err = io.Copy(tempFile, resp.Body); err != nil {\n\treturn fmt.Errorf(\"failed to save the downloaded archive: %w\", err)\n}","handlingStrategy":"validation","validationCode":"if resp.StatusCode != http.StatusOK {\n\treturn fmt.Errorf(\"download failed: %s\", resp.Status)\n}\n// pre-check free space when Content-Length is known\nif resp.ContentLength > 0 {\n\tif st, err := os.Stat(os.TempDir()); err == nil {\n\t\t_ = st // additionally use syscall.Statfs for free space in production\n\t}\n}","typeGuard":null,"tryCatchPattern":"n, err := io.Copy(tempFile, resp.Body)\nif err != nil {\n\tif resp.ContentLength > 0 && n < resp.ContentLength {\n\t\treturn fmt.Errorf(\"truncated download (%d/%d bytes): %w\", n, resp.ContentLength, err)\n\t}\n\treturn fmt.Errorf(\"failed to save the downloaded archive: %w\", err)\n}","preventionTips":["Ensure adequate free disk space before large downloads","Download on a stable connection; retry on truncation","Check HTTP status before writing the body","Watch for proxies that cut long-running transfers"],"tags":["filesystem","network","io","disk-full"],"backgroundTag":"disk-full","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}