kubernetes/kops · error

error adding expanded asset files in %q: %v

Error message

error adding expanded asset files in %q: %v

What it means

addArchive calls filepath.Walk over the extracted tree; Walk stops at the first error returned by the walker, and addArchive wraps it as 'error adding expanded asset files in %q: %v' (extracted dir plus the inner error). It is the top-level wrapper for any failure while registering extracted files as assets, including errors 1803/1804.

Source

Thrown at upup/pkg/fi/assetstore.go:358

		assetPath := path.Join(assetBase, relativePath)
		key := info.Name()
		r := NewFileResource(localPath)

		asset := &asset{
			Key:       key,
			AssetPath: assetPath,
			resource:  r,
			source:    &Source{Parent: archiveSource, ExtractFromArchive: assetPath},
		}
		klog.V(2).Infof("added asset %q for %q", asset.Key, asset.resource)
		a.assets = append(a.assets, asset)

		return nil
	}

	err := filepath.Walk(localBase, walker)
	if err != nil {
		return fmt.Errorf("error adding expanded asset files in %q: %v", extracted, err)
	}
	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the inner %v error first — this wrapper only names the extracted directory; the root cause is the nested error.
  2. Apply the fix indicated by the inner error (permissions, re-extract, etc.).
  3. Re-run the kOps command after fixing; the asset store will re-attempt extraction and registration.
  4. If extraction succeeds but registration repeatedly fails, clear the extracted dir and retry from scratch.
Defensive patterns

Strategy: try-catch

Validate before calling

import fs from "fs" // ensure extracted root exists and is traversable before the walk phase
fs.accessSync(extracted, fs.constants.R_OK | fs.constants.X_OK)

Type guard

function hasCause(e: unknown): e is { message: string; cause?: unknown } {
  return typeof e === "object" && e !== null && "message" in e
}

Try / catch

try {
  await addURLs(urls)
} catch (e) {
  if (/error adding expanded asset files/.test(e.message)) {
    // this is a wrapper — the inner %v names the real cause (walker error)
    console.error("asset registration failed:", e.message)
  }
  throw e
}

Prevention

When it happens

Trigger: addURLs -> addArchive: any error bubbled from the walker callback (unreadable entry, Rel failure) causes filepath.Walk to abort and this wrapper to be returned.

Common situations: Same real-world causes as the inner errors: permission-restricted files in the archive, files removed mid-walk, or the corrupted-archive cascades from extraction.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/3d5cea15cca3fee2. Report an issue: GitHub.