{"record":{"id":"616db188f06e7363","repo":"github/copilot-sdk","slug":"failed-to-write-runtime-assets-w","errorCode":null,"errorMessage":"failed to write runtime assets: %w","messagePattern":"failed to write runtime assets: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":499,"sourceCode":"\twrapperName := runtimeWrapperName(info.binaryName)\n\trawWrapperPath := filepath.Join(tempDir, wrapperName)\n\tif err := extractFileFromTarball(\n\t\ttarballPath,\n\t\ttempDir,\n\t\t\"package/prebuilds/\"+info.runtimePlatform+\"/\"+wrapperName,\n\t\twrapperName,\n\t); err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"runtime package is missing prebuilds/%s/%s: %w\", info.runtimePlatform, wrapperName, err)\n\t}\n\twrapperHash, err := sha256File(rawWrapperPath)\n\tif err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to hash runtime wrapper: %w\", err)\n\t}\n\tif err := compressZstdFile(rawWrapperPath, wrapperArtifactPath); err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to write runtime wrapper: %w\", err)\n\t}\n\tif err := createRuntimeAssetsArchive(tarballPath, assetsArtifactPath, info); err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to write runtime assets: %w\", err)\n\t}\n\tassetsHash, err := sha256File(assetsArtifactPath)\n\tif err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to hash runtime assets: %w\", err)\n\t}\n\n\tfmt.Printf(\"Successfully created %s\\n\", outputPath)\n\tfmt.Printf(\"Successfully created %s\\n\", runtimeArtifactPath)\n\tfmt.Printf(\"Successfully created %s\\n\", wrapperArtifactPath)\n\tfmt.Printf(\"Successfully created %s\\n\", assetsArtifactPath)\n\treturn bundleArtifacts{outputPath, binaryHash, runtimeArtifactPath, runtimeHash, wrapperArtifactPath, wrapperHash, assetsArtifactPath, assetsHash}, nil\n}\n\nfunc filesExist(paths ...string) bool {\n\tfor _, path := range paths {\n\t\tif _, err := os.Stat(path); err != nil {\n\t\t\treturn false\n\t\t}","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L481-L517","documentation":"This error wraps a failure from createRuntimeAssetsArchive, which repacks the downloaded CLI tarball into the runtime assets archive (gzipped tar). The bundler throws it during buildBundle when the runtime package could not be produced (e.g. tar/gzip stream errors, no retained assets, or I/O failure). It aborts bundle creation since the assets artifact is required.","triggerScenarios":"createRuntimeAssetsArchive returns any error while writing the gzipped tar of retained assets in buildBundle: source tar read failure, gzip/tar writer close failure, or the archive containing zero retained entries.","commonSituations":"Downloaded/cached CLI tarball is corrupt or empty so no assets are retained; destination disk full preventing gzip writes; running against a release whose package layout changed and the filter retains nothing; premature EOF from an interrupted tarball download.","solutions":["Delete the cached/intermediate tarball and re-run the bundler so a fresh, complete release package is downloaded","Check available disk space on the output/temp filesystem","Verify the release version and baseURL point to a package with the expected asset layout; update filter logic if assets are being filtered out","Inspect the wrapped error (%w chain) for the underlying tar/gzip/I/O cause"],"exampleFix":"// before\nif err := createRuntimeAssetsArchive(tarballPath, assetsArtifactPath, info); err != nil {\n\treturn bundleArtifacts{}, fmt.Errorf(\"failed to write runtime assets: %w\", err)\n}\n// after\nif err := createRuntimeAssetsArchive(tarballPath, assetsArtifactPath, info); err != nil {\n\tif errors.Is(err, errNoRetainedAssets) {\n\t\tos.Remove(tarballPath) // drop corrupt/partial tarball so next run re-downloads\n\t}\n\treturn bundleArtifacts{}, fmt.Errorf(\"failed to write runtime assets: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"if fi, err := os.Stat(tarballPath); err != nil || fi.Size() == 0 {\n\treturn fmt.Errorf(\"source tarball %s missing or empty; re-download before bundling\", tarballPath)\n}","typeGuard":"func tarballLooksValid(path string) bool {\n\tf, err := os.Open(path)\n\tif err != nil { return false }\n\tdefer f.Close()\n\tmagic := make([]byte, 2)\n\tif _, err := io.ReadFull(f, magic); err != nil { return false }\n\treturn magic[0] == 0x1f && magic[1] == 0x8b\n}","tryCatchPattern":"if err := buildBundle(...); err != nil {\n\tvar wrapped *os.PathError\n\tif errors.As(err, &wrapped) && errors.Is(wrapped, syscall.ENOSPC) {\n\t\t// free disk space and retry\n\t}\n\treturn fmt.Errorf(\"bundle build failed: %w\", err)\n}","preventionTips":["Validate the downloaded tarball's magic bytes and size before archiving","Check free disk space before running the bundler","Log the full wrapped error chain to identify tar vs gzip vs I/O causes","Pin the CLI release version so package layout stays predictable"],"tags":["go","bundler","file-write","archive"],"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-15T23:17:13.987Z"}