{"record":{"id":"ac97b85d9d1cf4a7","repo":"kubernetes/kops","slug":"error-expanding-asset-file-q-v-s","errorCode":null,"errorMessage":"error expanding asset file %q %v: %s","messagePattern":"error expanding asset file %q (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/assetstore.go","lineNumber":315,"sourceCode":"\nfunc (a *AssetStore) addArchive(archiveSource *Source, archiveFile string) error {\n\textracted := path.Join(a.cacheDir, \"extracted/\"+path.Base(archiveFile))\n\n\tif _, err := os.Stat(extracted); os.IsNotExist(err) {\n\t\t// We extract to a temporary dir which we then rename so this is atomic\n\t\t// (untarring can be slow, and we might crash / be interrupted half-way through)\n\t\textractedTemp := extracted + \".tmp-\" + strconv.FormatInt(time.Now().UnixNano(), 10)\n\t\terr := os.MkdirAll(extractedTemp, 0o755)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error creating directories %q: %v\", path.Dir(extractedTemp), err)\n\t\t}\n\n\t\targs := []string{\"tar\", \"zxf\", archiveFile, \"-C\", extractedTemp}\n\t\tklog.Infof(\"running extract command %s\", args)\n\t\tcmd := exec.Command(args[0], args[1:]...)\n\t\toutput, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error expanding asset file %q %v: %s\", archiveFile, err, string(output))\n\t\t}\n\n\t\tif err := os.Rename(extractedTemp, extracted); err != nil {\n\t\t\treturn fmt.Errorf(\"error renaming extracted temp dir %s -> %s: %v\", extractedTemp, extracted, err)\n\t\t}\n\t}\n\n\tlocalBase := extracted\n\tassetBase := \"\"\n\n\twalker := func(localPath string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error descending into path %q: %v\", localPath, err)\n\t\t}\n\n\t\tif info.IsDir() {\n\t\t\treturn nil\n\t\t}","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/assetstore.go#L297-L333","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// verify archive manually before running the kOps operation\n$ file nodeup.tar.gz            # expect: gzip compressed data\n$ tar -tzf nodeup.tar.gz        # must list entries without error\n$ sha256sum nodeup.tar.gz       # compare with published checksum","handlingStrategy":"validation","validationCode":"import { execSync } from \"child_process\" // verify archive before handing to kOps\nexecSync(`tar -tzf ${archiveFile}`, { stdio: \"ignore\" }) // throws if not a valid gzip/tar\nexecSync(`sha256sum -c ${archiveFile}.sha256`) // checksum check","typeGuard":"function looksLikeGzip(buf: Buffer): boolean { return buf.length > 2 && buf[0] === 0x1f && buf[1] === 0x8b }","tryCatchPattern":"try {\n  await addURLs(urls)\n} catch (e) {\n  if (/error expanding asset file/.test(e.message)) {\n    console.error(\"tar failed; output:\", e.message) // error text embeds tar's CombinedOutput\n    // re-download and verify checksum before retrying\n  }\n  throw e\n}","preventionTips":["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."],"tags":["archive","tar","assets"],"backgroundTag":"archive-extraction-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}