{"record":{"id":"2e022f4f0eb4599f","repo":"github/copilot-sdk","slug":"failed-to-extract-binary-w","errorCode":null,"errorMessage":"failed to extract binary: %w","messagePattern":"failed to extract binary: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":1185,"sourceCode":"\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\n\t\tif header.Name == targetPath {\n\t\t\toutPath := filepath.Join(destDir, outputName)\n\t\t\toutFile, err := os.OpenFile(outPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.FileMode(header.Mode))\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create output file: %w\", err)\n\t\t\t}\n\n\t\t\tif _, err := io.Copy(outFile, tarReader); err != nil {\n\t\t\t\tif cerr := outFile.Close(); cerr != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to extract binary (copy error: %v, close error: %v)\", err, cerr)\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"failed to extract binary: %w\", err)\n\t\t\t}\n\t\t\tif err := outFile.Close(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to close output file: %w\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn fmt.Errorf(\"file %q not found in tarball\", targetPath)\n}\n\n// extractOptionalFileFromTarball extracts a single file from a .tgz into destDir\n// like extractFileFromTarball, but returns (false, nil) instead of an error when\n// the file is absent. Used for the runtime library, which older CLI packages do\n// not ship.\nfunc extractOptionalFileFromTarball(tarballPath, destDir, targetPath, outputName string) (bool, error) {\n\terr := extractFileFromTarball(tarballPath, destDir, targetPath, outputName)\n\tif err == nil {","sourceCodeStart":1167,"sourceCodeEnd":1203,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L1167-L1203","documentation":"io.Copy failed while writing the matched tar entry (the binary) to the output file, but outFile.Close() succeeded and its error is not included. This is the plain write/transfer failure path of extractFileFromTarball.","triggerScenarios":"extractFileFromTarball (from buildBundle, downloadCLIBinary, extractOptionalFileFromTarball) encounters a corrupt or truncated tar/gzip stream mid-entry, or a disk-full/ENOSPC write error while copying the binary payload.","commonSituations":"Corrupted release downloads on CI; full disks on runners; network-mounted output volumes dropping mid-write; truncated artifacts from interrupted downloads.","solutions":["Re-download the artifact and validate its checksum before extraction","Ensure sufficient free disk space on the destination volume","Verify the tarball manually (tar -tzf) to confirm integrity","Retry the extraction/installation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if err := verifyChecksum(tarballPath, expectedSHA256); err != nil { return fmt.Errorf(\"corrupt tarball: %w\", err) }\nif free, err := diskFree(destDir); err == nil && free < minRequiredBytes { return fmt.Errorf(\"insufficient disk space\") }","typeGuard":null,"tryCatchPattern":"if err := extractFileFromTarball(tgz, destDir, target, out); err != nil {\n    if strings.Contains(err.Error(), \"failed to extract binary\") && strings.Contains(err.Error(), \"no space left\") { return fmt.Errorf(\"disk full while installing; free space and retry\") }\n    return err\n}","preventionTips":["Verify artifact checksums before extraction","Monitor disk space on CI runners before installs","Extract to reliable local storage rather than network mounts","Treat ENOSPC errors as disk issues, not code bugs"],"tags":["go","io-copy","tarball","disk-full"],"backgroundTag":"file-write-failed","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}