{"record":{"id":"f91c280ec4e26f91","repo":"github/copilot-sdk","slug":"failed-to-save-tarball-w","errorCode":null,"errorMessage":"failed to save tarball: %w","messagePattern":"failed to save tarball: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":1022,"sourceCode":"\t\treturn \"\", \"\", fmt.Errorf(\"failed to download: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to download: %s\", resp.Status)\n\t}\n\n\t// Save tarball to temp file\n\ttarballPath := filepath.Join(destDir, assetName)\n\ttarballFile, err := os.Create(tarballPath)\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to create tarball file: %w\", err)\n\t}\n\n\thasher := sha256.New()\n\tif _, err := io.Copy(io.MultiWriter(tarballFile, hasher), resp.Body); err != nil {\n\t\ttarballFile.Close()\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to save tarball: %w\", err)\n\t}\n\tif err := tarballFile.Close(); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to close tarball file: %w\", err)\n\t}\n\tactualChecksum := fmt.Sprintf(\"%x\", hasher.Sum(nil))\n\tif actualChecksum != expectedChecksum {\n\t\treturn \"\", \"\", fmt.Errorf(\n\t\t\t\"checksum mismatch for %s: expected %s, got %s\",\n\t\t\tassetName,\n\t\t\texpectedChecksum,\n\t\t\tactualChecksum,\n\t\t)\n\t}\n\n\t// The SDK release package intentionally omits the legacy SEA binary. Preserve\n\t// embeddedcli.Path compatibility by installing the runtime wrapper under the\n\t// historical copilot[.exe] name; the normal client path uses the adjacent\n\t// wrapper/runtime.node pair directly.","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L1004-L1040","documentation":"downloadCLIBinary streams the release tarball from the network into a local file while simultaneously computing its SHA-256 via io.MultiWriter. This error wraps any failure from that io.Copy of resp.Body, meaning the download was interrupted or the write to the tarball file failed mid-stream. It is thrown to distinguish save-time I/O problems from earlier file-creation problems.","triggerScenarios":"io.Copy(io.MultiWriter(tarballFile, hasher), resp.Body) returns a non-nil error while downloading the release tarball — network drop, connection reset, disk full while writing the file, or the HTTP body read failing.","commonSituations":"Flaky network or proxy dropping long downloads of large CLI binaries; disk quota/full /tmp; corporate firewall terminating TLS mid-transfer; transient GitHub release-asset download failure.","solutions":["Retry the download; the error is usually transient (network or disk pressure).","Check free disk space on the destination filesystem (tarballs plus extracted binaries can be hundreds of MB).","Verify network/proxy stability (HTTP_PROXY, VPN, firewall) and re-run buildBundle.","Check upstream release-host availability if failures persist across retries."],"exampleFix":"// before: single-shot download with no retry\ntarballPath, licensePath, err := downloadCLIBinary(...)\n\n// after: retry transient save failures\nvar tarballPath, licensePath string\nfor attempt := 0; attempt < 3; attempt++ {\n    tarballPath, licensePath, err = downloadCLIBinary(...)\n    if err == nil || !strings.Contains(err.Error(), \"failed to save tarball\") {\n        break\n    }\n    time.Sleep(time.Duration(attempt+1) * 2 * time.Second)\n}","handlingStrategy":"retry","validationCode":"// preflight disk space before downloading\nif st, err := os.Statfs(destDir); err == nil && st.Avail < 1<<30 {\n    return fmt.Errorf(\"insufficient space in %s for tarball download\", destDir)\n}","typeGuard":null,"tryCatchPattern":"for i := 0; i < 3; i++ {\n    path, lic, err := downloadCLIBinary(...)\n    if err == nil { break }\n    if isIOCopyFailure(err) { time.Sleep(backoff(i)); continue }\n    return err\n}","preventionTips":["Ensure ample free disk space on the destination filesystem before bundling.","Use a stable network connection or resumable download for large assets.","Wrap the download in bounded retries with backoff.","Monitor proxy/VPN stability in CI environments."],"tags":["network","io","download","go"],"backgroundTag":"network-request-failed","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"}