{"record":{"id":"9a687bfa4c98cf3c","repo":"GoogleContainerTools/skaffold","slug":"applying-default-repo-to-q-w","errorCode":null,"errorMessage":"applying default repo to %q: %w","messagePattern":"applying default repo to %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/util/util.go","lineNumber":69,"sourceCode":"var (\n\tconfirmHydrationDirOverride = prompt.ConfirmHydrationDirOverride\n)\n\n// ApplyDefaultRepo applies the default repo to a given image tag.\nfunc ApplyDefaultRepo(globalConfig string, defaultRepo *string, tag string) (string, error) {\n\trepo, err := config.GetDefaultRepo(globalConfig, defaultRepo)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"getting default repo: %w\", err)\n\t}\n\n\tmultiLevel, err := config.GetMultiLevelRepo(globalConfig)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"getting multi-level repo support: %w\", err)\n\t}\n\n\tnewTag, err := docker.SubstituteDefaultRepoIntoImage(repo, multiLevel, tag)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"applying default repo to %q: %w\", tag, err)\n\t}\n\n\treturn newTag, nil\n}\n\n// Update which images are logged, if the image is present in the provided deployer's artifacts.\nfunc AddTagsToPodSelector(runnerBuilds []graph.Artifact, deployerArtifacts []graph.Artifact, podSelector *kubernetes.ImageList) {\n\t// This implementation is mostly picked from v1 for fixing log duplication issue when multiple deployers are used.\n\t// According to the original author \"Each Deployer will be directly responsible for adding its deployed artifacts to the PodSelector\n\t// by cross-referencing them against the list of images parsed out of the set of manifests they each deploy\". Each deploy should only\n\t// add its own deployed artifacts to the PodSelector to avoid duplicate logging when multi-deployers are used.\n\t// This implementation only streams logs for the intersection of runnerBuilds and deployerArtifacts images, not all images from a deployer\n\t// probably because at that time the team didn't want to stream logs from images not built by Skaffold, e.g. images from docker hub, but this\n\t// may change. The initial implementation was using imageName as map key for getting shared elements, this was ok as deployerArtifacts were\n\t// parsed out from skaffold config files in v1 and tag was not available if not specified. Now deployers don't own render responsibilities\n\t// anymore, instead callers pass rendered manifests to deployers, we can only parse artifacts from these rendered manifests. The imageName\n\t// from deployerArtifacts here has the default-repo value as prefix while the one from runnerBuilds doesn't. This discrepancy causes artifact.Tag\n\t// fail to add into podSelector, which leads to podWatchers fail to get events from pods. As tags are available in deployerArtifacts now, so using","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/util/util.go#L51-L87","documentation":"ApplyDefaultRepo wraps a failed attempt to rewrite an image tag so it is prefixed with the user's default repository (e.g. gcr.io/mine). It calls docker.SubstituteDefaultRepoIntoImage, and if that substitution fails (after successfully reading multi-level repo support), the original tag and the underlying error are wrapped. This lets callers like ImageTags report which image tag could not be remapped.","triggerScenarios":"Calling ApplyDefaultRepo (directly or via ImageTags) when docker.SubstituteDefaultRepoIntoImage returns an error for the given tag/repo combination — e.g. the tag cannot be parsed or is incompatible with the repo's multi-level support setting.","commonSituations":"Misconfigured default-repository setting in skaffold.yaml; image names with unexpected registries or nested paths that don't fit the multi-level repo rules; empty or malformed image tag passed in from build output.","solutions":["Check the wrapped inner error from SubstituteDefaultRepoIntoImage to see why the tag could not be rewritten","Verify the default repository configured (e.g. via --default-repo or skaffold.yaml defaultRepo) is a valid registry path","Confirm the image tag is a fully-qualified, parseable docker image reference (registry/name:tag)","If the repo is known to be multi-level incompatible, set multiLevel accordingly instead of forcing substitution"],"exampleFix":"// before\nnewTag, err := docker.SubstituteDefaultRepoIntoImage(repo, multiLevel, tag)\nif err != nil {\n\treturn \"\", fmt.Errorf(\"applying default repo to %q: %w\", tag, err)\n}\n// after\nnewTag, err := docker.SubstituteDefaultRepoIntoImage(repo, multiLevel, tag)\nif err != nil {\n\treturn \"\", fmt.Errorf(\"applying default repo to %q: %w\", tag, err)\n}","handlingStrategy":"validation","validationCode":"func validateTagForDefaultRepo(tag string) error {\n\tif tag == \"\" {\n\t\treturn fmt.Errorf(\"empty image tag\")\n\t}\n\tref, err := docker.ParseReference(tag)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot parse image tag %q: %w\", tag, err)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := ImageTags(...); err != nil {\n\tif strings.Contains(err.Error(), \"applying default repo\") {\n\t\tlog.Warnf(\"default repo substitution failed: %v — using original tag\", err)\n\t\treturn originalTag, nil\n\t}\n\treturn err\n}","preventionTips":["Validate image references are fully qualified before build output is consumed","Keep the default-repo config simple and verified with a test push","Log the full wrapped error chain to see SubstituteDefaultRepoIntoImage's cause","Check multi-level repo support settings match your registry's path structure"],"tags":["docker","image-tags","configuration","error-wrapping"],"backgroundTag":"image-repo-substitution-failed","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"}