kubernetes/kops · error
error expanding asset file %q %v: %s
Error message
error expanding asset file %q %v: %s
What it means
After creating a temp dir, addArchive runs 'tar zxf <archiveFile> -C <extractedTemp>'. If tar exits nonzero (it also captures stderr via CombinedOutput), the asset store fails with 'error expanding asset file %q %v: %s' including the tar output so the developer can see why extraction failed.
Source
Thrown at upup/pkg/fi/assetstore.go:315
func (a *AssetStore) addArchive(archiveSource *Source, archiveFile string) error {
extracted := path.Join(a.cacheDir, "extracted/"+path.Base(archiveFile))
if _, err := os.Stat(extracted); os.IsNotExist(err) {
// We extract to a temporary dir which we then rename so this is atomic
// (untarring can be slow, and we might crash / be interrupted half-way through)
extractedTemp := extracted + ".tmp-" + strconv.FormatInt(time.Now().UnixNano(), 10)
err := os.MkdirAll(extractedTemp, 0o755)
if err != nil {
return fmt.Errorf("error creating directories %q: %v", path.Dir(extractedTemp), err)
}
args := []string{"tar", "zxf", archiveFile, "-C", extractedTemp}
klog.Infof("running extract command %s", args)
cmd := exec.Command(args[0], args[1:]...)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("error expanding asset file %q %v: %s", archiveFile, err, string(output))
}
if err := os.Rename(extractedTemp, extracted); err != nil {
return fmt.Errorf("error renaming extracted temp dir %s -> %s: %v", extractedTemp, extracted, err)
}
}
localBase := extracted
assetBase := ""
walker := func(localPath string, info os.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("error descending into path %q: %v", localPath, err)
}
if info.IsDir() {
return nil
}View on GitHub (pinned to 4c8573c808)
Solutions
- Read the trailing %s field of the error — it contains tar's CombinedOutput with the exact failure.
- Verify the archive integrity (tar -tzf <file>, sha256 vs upstream checksum).
- Re-download the asset after clearing caches/proxies that may serve corrupt bodies.
- Ensure the file is actually a gzipped tarball (not zip or plain binary) and matches the expected version.
- If tar is failing on permissions/paths shown in output, fix those before retrying.
Example fix
// verify archive manually before running the kOps operation $ file nodeup.tar.gz # expect: gzip compressed data $ tar -tzf nodeup.tar.gz # must list entries without error $ sha256sum nodeup.tar.gz # compare with published checksum
Defensive patterns
Strategy: validation
Validate before calling
import { execSync } from "child_process" // verify archive before handing to kOps
execSync(`tar -tzf ${archiveFile}`, { stdio: "ignore" }) // throws if not a valid gzip/tar
execSync(`sha256sum -c ${archiveFile}.sha256`) // checksum check Type guard
function looksLikeGzip(buf: Buffer): boolean { return buf.length > 2 && buf[0] === 0x1f && buf[1] === 0x8b } Try / catch
try {
await addURLs(urls)
} catch (e) {
if (/error expanding asset file/.test(e.message)) {
console.error("tar failed; output:", e.message) // error text embeds tar's CombinedOutput
// re-download and verify checksum before retrying
}
throw e
} Prevention
- Verify sha256 of downloaded assets before use.
- Beware proxies/mirrors that return HTML error pages with 200.
- Confirm the asset is a .tar.gz (not zip/plain binary).
- Re-download on flaky networks; truncated tarballs fail here.
When it happens
Trigger: addURLs -> addArchive where the downloaded file is not a valid gzip/tar archive, is truncated/corrupt, is empty, or the tar binary is missing/fails for any reason.
Common situations: Corrupted download from a mirror or proxy injecting HTML error pages into the tarball; truncated download on flaky network; wrong file uploaded to the asset location; checksum mismatch not detected upstream.
Related errors
- unable to marshal YAML: %v
- unable to marshal JSON: %v
- unable to find any containerd binaries in assets
- error finding runc asset
- unable to locate asset %q
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/ac97b85d9d1cf4a7.
Report an issue: GitHub.