{"record":{"id":"cb4d379fd3a49d28","repo":"kubernetes/kops","slug":"error-remapping-images-v","errorCode":null,"errorMessage":"error remapping images: %v","messagePattern":"error remapping images: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/assets/builder.go","lineNumber":250,"sourceCode":"\t\treturn snapshot[i].Path < snapshot[j].Path\n\t})\n\n\treturn snapshot\n}\n\n// RemapManifest transforms a kubernetes manifest.\n// Whenever we are building a Task that includes a manifest, we should pass it through RemapManifest first.\n// This will:\n// * rewrite the images if they are being redirected to a mirror, and ensure the image is uploaded\nfunc (a *AssetBuilder) RemapManifest(data []byte) ([]byte, error) {\n\tobjects, err := kubemanifest.LoadObjectsFrom(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, object := range objects {\n\t\tif err := object.RemapImages(a.RemapImage); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error remapping images: %v\", err)\n\t\t}\n\t}\n\n\treturn objects.ToYAML()\n}\n\n// RemapImage normalizes a containers location if a user sets the AssetsLocation ContainerRegistry location.\nfunc (a *AssetBuilder) RemapImage(image string) string {\n\tasset := &ImageAsset{\n\t\tDownloadLocation:  image,\n\t\tCanonicalLocation: image,\n\t}\n\n\tif strings.HasPrefix(image, \"registry.k8s.io/kops/dns-controller:\") {\n\t\t// To use user-defined DNS Controller:\n\t\t// 1. DOCKER_REGISTRY=[your docker hub repo] make dns-controller-push\n\t\t// 2. export DNSCONTROLLER_IMAGE=[your docker hub repo]\n\t\t// 3. make kops and create/apply cluster","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/assets/builder.go#L232-L268","documentation":"AssetBuilder.RemapManifest wraps any error returned while remapping the container images of objects parsed from a manifest YAML. The underlying failure came from one of the objects' RemapImages callbacks (a.RemapImage), typically a failure to compute or resolve a remapped image URL/hash. The %v is the root cause, so the real fix depends on the wrapped error text.","triggerScenarios":"Calling RemapManifest on a manifest whose objects contain images that fail remapping — e.g. RemapImage returns an error for an unparseable image reference, or hash lookup/download fails for an image while building an addon/cluster manifest.","commonSituations":"Staging assets with a misconfigured --assets-location; addon manifests referencing images unavailable in a private registry; malformed image names in manifests; network failures downloading image hashes.","solutions":["Read the wrapped %v cause and fix the underlying image (bad reference, missing hash, unreachable registry).","If using a file/oci assets mirror, run 'kops get assets --copy' to stage all images, then retry.","Verify AssetsLocation/registry settings on the AssetBuilder match the staged mirror.","Test the manifest standalone with TestRemapEmptySection-style parsing to find the offending object/image."],"exampleFix":"// before\nassetBuilder.AssetsLocation = &mirrors.AssetLocation{RegistryMirror: \"registry.example.com/kops\"} // mirror not populated\n// after\n// stage assets first:\n//   kops get assets --copy --asset-file-repository registry.example.com/kops\nassetBuilder.AssetsLocation = &mirrors.AssetLocation{RegistryMirror: \"registry.example.com/kops\"}","handlingStrategy":"try-catch","validationCode":"// pre-flight: check every image in the manifest is parseable\nfor _, img := range manifestImages(manifestYAML) {\n\tif _, _, err := image.ParseNormalizedNamed(img); err != nil {\n\t\treturn fmt.Errorf(\"unparseable image %q: %w\", img, err)\n\t}\n}","typeGuard":"func hasRemappableObjects(objects api.YAMLObjects) bool { return len(objects.Items) > 0 }","tryCatchPattern":"objects, err := assetBuilder.RemapManifest(manifestYAML)\nif err != nil {\n\tif strings.Contains(err.Error(), \"error remapping images:\") {\n\t\tcause := strings.TrimPrefix(err.Error(), \"error remapping images: \")\n\t\treturn fmt.Errorf(\"manifest image remap failed, root cause: %s\", cause)\n\t}\n\treturn err\n}","preventionTips":["Validate all image references in manifests before building assets.","Populate and verify the assets mirror with 'kops get assets --copy' before cluster operations.","Keep the wrapped error text; it names the failing image or hash.","Pin supported Kubernetes versions so hash/image metadata is published."],"tags":["assets","image-remapping","manifest"],"backgroundTag":"image-remap-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"}