{"record":{"id":"eabad57c2e8bd29e","repo":"GoogleContainerTools/skaffold","slug":"tagging-policy-sha256-can-not-be-used-when-tryi","errorCode":null,"errorMessage":"tagging policy 'sha256' can not be used when 'tryImportMissing' is enabled","messagePattern":"tagging policy 'sha256' can not be used when 'tryImportMissing' is enabled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/schema/validation/validation.go","lineNumber":145,"sourceCode":"\terrs = append(errs, validateCustomActionsExecModes(runCtx)...)\n\n\tif len(errs) == 0 {\n\t\treturn nil\n\t}\n\tvar messages []string\n\tfor _, err := range errs {\n\t\tmessages = append(messages, err.Error())\n\t}\n\treturn errors.New(strings.Join(messages, \" \\n \"))\n}\n\n// validateTaggingPolicy checks that the tagging policy is valid in combination with other options.\nfunc validateTaggingPolicy(cfg *parser.SkaffoldConfigEntry, bc latest.BuildConfig) (cfgErrs []ErrorWithLocation) {\n\tif bc.LocalBuild != nil {\n\t\t// sha256 just uses `latest` tag, so tryImportMissing will virtually always succeed (#4889)\n\t\tif bc.LocalBuild.TryImportMissing && bc.TagPolicy.ShaTagger != nil {\n\t\t\tcfgErrs = append(cfgErrs, ErrorWithLocation{\n\t\t\t\tError:    errors.New(\"tagging policy 'sha256' can not be used when 'tryImportMissing' is enabled\"),\n\t\t\t\tLocation: cfg.YAMLInfos.Locate(cfg.Build.TagPolicy.ShaTagger),\n\t\t\t})\n\t\t}\n\t}\n\treturn\n}\n\n// validateImageNames makes sure the artifact image names are unique and valid base names,\n// without tags nor digests.\nfunc validateImageNames(configs parser.SkaffoldConfigSet) (errs []ErrorWithLocation) {\n\tseen := make(map[string]string)\n\tarMap := make(map[string]*latest.Artifact)\n\n\tfor _, c := range configs {\n\t\tfor i, a := range c.Build.Artifacts {\n\t\t\tcurLines := c.YAMLInfos.Locate(c.Build.Artifacts[i])\n\t\t\tif prevSource, found := seen[a.ImageName]; found {\n\t\t\t\tprevLines := c.YAMLInfos.Locate(arMap[c.Build.Artifacts[i].ImageName])","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/schema/validation/validation.go#L127-L163","documentation":"The sha256 tagger always uses the 'latest' tag, which conflicts with build.local.tryImportMissing (which relies on previously built images). If both are configured, validateTaggingPolicy records this error with the location of the sha256 tagger.","triggerScenarios":"skaffold.yaml with build.local.tryImportMissing: true and build.tagPolicy.sha256 set; reported via ProcessToErrorWithLocation.","commonSituations":"Users enabling tryImportMissing to reuse images while keeping the default/selected sha256 tagger, then running validation.","solutions":["Switch the tag policy to gitCommit or envTemplate (or another non-sha256 tagger) when tryImportMissing is enabled.","Set build.local.tryImportMissing: false if sha256 tagging is required.","Remove the explicit sha256 tagPolicy so a compatible policy is used."],"exampleFix":"# before\nbuild:\n  local:\n    tryImportMissing: true\n  tagPolicy:\n    sha256: {}\n# after\nbuild:\n  local:\n    tryImportMissing: true\n  tagPolicy:\n    gitCommit: {}","handlingStrategy":"validation","validationCode":"func sha256WithTryImport(bc latest.BuildConfig) bool {\n    return bc.LocalBuild != nil && bc.LocalBuild.TryImportMissing && bc.TagPolicy.ShaTagger != nil\n}","typeGuard":"if bc.LocalBuild != nil && bc.LocalBuild.TryImportMissing && bc.TagPolicy.ShaTagger != nil { /* invalid combo */ }","tryCatchPattern":"errs := validation.ProcessToErrorWithLocation(cfg)\nfor _, e := range errs {\n    if strings.Contains(e.Error.Error(), \"sha256\") && strings.Contains(e.Error.Error(), \"tryImportMissing\") {\n        // switch tag policy or disable tryImportMissing\n    }\n}","preventionTips":["Never combine sha256 tagger with tryImportMissing","Prefer gitCommit or envTemplate taggers when reusing images","Validate configs after any tagPolicy/local build edits"],"tags":["validation","tagging-policy","sha256"],"backgroundTag":"schema-validation-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"}