{"record":{"id":"450c693b9449d080","repo":"GoogleContainerTools/skaffold","slug":"loading-artifacts-w","errorCode":null,"errorMessage":"loading artifacts: %w","messagePattern":"loading artifacts: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/skaffold/app/cmd/render.go","lineNumber":69,"sourceCode":"}\n\nfunc doRender(ctx context.Context, out io.Writer) error {\n\t// TODO(nkubala): remove this from opts in favor of a param to Build()\n\topts.RenderOnly = true\n\tbuildOut := io.Discard\n\tif showBuild {\n\t\tbuildOut = out\n\t}\n\n\treturn withRunner(ctx, out, func(r runner.Runner, configs []util.VersionedConfig) error {\n\t\tvar bRes []graph.Artifact\n\t\tvar err error\n\n\t\tif fromBuildOutputFile.String() != \"\" || len(preBuiltImages.GetSlice()) > 0 {\n\t\t\t// pass `nil` as render shouldn't build if provided --build-artifacts or --images\n\t\t\tbRes, err = getBuildArtifactsAndSetTags(nil, r.ApplyDefaultRepo)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"loading artifacts: %w\", err)\n\t\t\t}\n\t\t} else {\n\t\t\tbRes, err = r.Build(ctx, buildOut, targetArtifacts(opts, configs))\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"executing build: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\tmanifests, err := r.Render(ctx, out, bRes, offline)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"rendering manifests: %w\", err)\n\t\t}\n\t\treturn manifest.Write(manifests.String(), opts.RenderOutput, out)\n\t})\n}\n","sourceCodeStart":51,"sourceCodeEnd":85,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/cmd/skaffold/app/cmd/render.go#L51-L85","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Verify the artifacts file exists and is valid JSON with the expected shape ({\"imageName\":{\"tag\":...}} / build-result format).","Ensure every artifact name in the file matches an image defined in skaffold.yaml.","Re-generate the artifacts file with a fresh `skaffold build -q > artifacts.json`.","Check --default-repo and ApplyDefaultRepo behavior; remove a malformed --default-repo value."],"exampleFix":"// before: stale artifacts file from a renamed image\nskaffold render --build-artifacts old-artifacts.json\n// after: regenerate artifacts from current config\nskaffold build -q > artifacts.json\nskaffold render --build-artifacts artifacts.json\n","handlingStrategy":"validation","validationCode":"// Validate the build-artifacts file before passing it to skaffold render\nconst fs = require('fs');\nconst raw = JSON.parse(fs.readFileSync('artifacts.json', 'utf8'));\nconst configured = ['gcr.io/proj/svc-a', 'gcr.io/proj/svc-b']; // image names from skaffold.yaml\nfor (const name of Object.keys(raw)) {\n  if (!configured.includes(name)) throw new Error(`artifact ${name} not in skaffold.yaml`);\n  const tag = typeof raw[name] === 'string' ? raw[name] : raw[name].tag;\n  if (!tag) throw new Error(`artifact ${name} has no tag`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  execFileSync('skaffold', ['render', '--build-artifacts', 'artifacts.json']);\n} catch (e) {\n  const msg = e.stderr?.toString() ?? '';\n  if (msg.includes('loading artifacts')) {\n    console.error('Bad artifacts file or image mismatch; regenerate with `skaffold build -q > artifacts.json`.');\n  } else throw e;\n}","preventionTips":["Always generate the artifacts file with `skaffold build -q` rather than hand-editing.","Regenerate artifacts.json whenever skaffold.yaml image names change.","Verify --default-repo is a valid registry reference when used with render.","Keep the artifacts file next to the pipeline step that produced it to avoid stale paths."],"tags":["skaffold","render","build-artifacts","images"],"backgroundTag":"invalid-build-artifacts-file","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}