GoogleContainerTools/skaffold · error

loading artifacts: %w

Error message

loading artifacts: %w

What it means

In `skaffold render`, when build artifacts are supplied up front (via --build-artifacts file or --images flags), render must load and re-tag them via getBuildArtifactsAndSetTags. This wrapper reports failures in that loading step. It means the pre-built images file is missing, malformed, or its artifact references don't match the skaffold config, so render cannot proceed without building.

Source

Thrown at cmd/skaffold/app/cmd/render.go:69

}

func doRender(ctx context.Context, out io.Writer) error {
	// TODO(nkubala): remove this from opts in favor of a param to Build()
	opts.RenderOnly = true
	buildOut := io.Discard
	if showBuild {
		buildOut = out
	}

	return withRunner(ctx, out, func(r runner.Runner, configs []util.VersionedConfig) error {
		var bRes []graph.Artifact
		var err error

		if fromBuildOutputFile.String() != "" || len(preBuiltImages.GetSlice()) > 0 {
			// pass `nil` as render shouldn't build if provided --build-artifacts or --images
			bRes, err = getBuildArtifactsAndSetTags(nil, r.ApplyDefaultRepo)
			if err != nil {
				return fmt.Errorf("loading artifacts: %w", err)
			}
		} else {
			bRes, err = r.Build(ctx, buildOut, targetArtifacts(opts, configs))
			if err != nil {
				return fmt.Errorf("executing build: %w", err)
			}
		}

		manifests, err := r.Render(ctx, out, bRes, offline)
		if err != nil {
			return fmt.Errorf("rendering manifests: %w", err)
		}
		return manifest.Write(manifests.String(), opts.RenderOutput, out)
	})
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Verify the artifacts file exists and is valid JSON with the expected shape ({"imageName":{"tag":...}} / build-result format).
  2. Ensure every artifact name in the file matches an image defined in skaffold.yaml.
  3. Re-generate the artifacts file with a fresh `skaffold build -q > artifacts.json`.
  4. Check --default-repo and ApplyDefaultRepo behavior; remove a malformed --default-repo value.

Example fix

// before: stale artifacts file from a renamed image
skaffold render --build-artifacts old-artifacts.json
// after: regenerate artifacts from current config
skaffold build -q > artifacts.json
skaffold render --build-artifacts artifacts.json
Defensive patterns

Strategy: validation

Validate before calling

// Validate the build-artifacts file before passing it to skaffold render
const fs = require('fs');
const raw = JSON.parse(fs.readFileSync('artifacts.json', 'utf8'));
const configured = ['gcr.io/proj/svc-a', 'gcr.io/proj/svc-b']; // image names from skaffold.yaml
for (const name of Object.keys(raw)) {
  if (!configured.includes(name)) throw new Error(`artifact ${name} not in skaffold.yaml`);
  const tag = typeof raw[name] === 'string' ? raw[name] : raw[name].tag;
  if (!tag) throw new Error(`artifact ${name} has no tag`);
}

Try / catch

try {
  execFileSync('skaffold', ['render', '--build-artifacts', 'artifacts.json']);
} catch (e) {
  const msg = e.stderr?.toString() ?? '';
  if (msg.includes('loading artifacts')) {
    console.error('Bad artifacts file or image mismatch; regenerate with `skaffold build -q > artifacts.json`.');
  } else throw e;
}

Prevention

When it happens

Trigger: `skaffold render --build-artifacts <file>` (or --images) where the JSON artifacts file is unreadable, is not valid JSON with the expected build-result shape, references artifacts absent from the config, or ApplyDefaultRepo fails while rewriting image names.

Common situations: Passing a build-output file from a previous run whose image names no longer match the current skaffold.yaml artifacts; hand-editing the artifacts JSON with wrong fields; forgetting the file argument points to the right path; default-repo rewrite failing due to malformed --default-repo.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/450c693b9449d080. Report an issue: GitHub.