{"record":{"id":"fe1b3f7add827ea9","repo":"GoogleContainerTools/skaffold","slug":"evaluating-custom-template-component-w","errorCode":null,"errorMessage":"evaluating custom template component: %w","messagePattern":"evaluating custom template component: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/tag/custom_template.go","lineNumber":101,"sourceCode":"\t\t\tgitTagger, _ := NewGitCommit(\"\", \"\", false)\n\t\t\ttaggers[field] = gitTagger\n\t\tcase \"DATE\":\n\t\t\ttaggers[field] = NewDateTimeTagger(\"\", \"\")\n\t\tcase \"SHA\":\n\t\t\ttaggers[field] = &ChecksumTagger{}\n\t\tcase \"INPUT_DIGEST\":\n\t\t\tinputDigestTagger, _ := NewInputDigestTagger(t.RunCtx, graph.ToArtifactGraph(t.RunCtx.Artifacts()))\n\t\t\ttaggers[field] = inputDigestTagger\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"no tagger available for component %+v\", field)\n\t\t}\n\t}\n\n\tcustomMap := map[string]string{}\n\tfor k, v := range taggers {\n\t\ttag, err := v.GenerateTag(ctx, image)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"evaluating custom template component: %w\", err)\n\t\t}\n\t\tcustomMap[k] = tag\n\t}\n\treturn customMap, nil\n}\n\n// ParseCustomTemplate is a simple wrapper to parse an custom template.\nfunc ParseCustomTemplate(t string) (*template.Template, error) {\n\treturn template.New(\"customTemplate\").Parse(t)\n}\n\n// ExecuteCustomTemplate executes a customTemplate against a custom map.\nfunc ExecuteCustomTemplate(customTemplate *template.Template, customMap map[string]string) (string, error) {\n\tvar buf bytes.Buffer\n\tlog.Entry(context.TODO()).Debugf(\"Executing custom template %v with custom map %v\", customTemplate, customMap)\n\tif err := customTemplate.Execute(&buf, customMap); err != nil {\n\t\treturn \"\", fmt.Errorf(\"executing template: %w\", err)\n\t}","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/tag/custom_template.go#L83-L119","documentation":"One of the component taggers failed while generating its tag string during custom template evaluation. After all taggers are collected, `EvaluateComponents` calls each tagger's `GenerateTag(ctx, image)`; any failure is wrapped with this message naming none of them directly but wrapping the underlying cause. The template is never executed.","triggerScenarios":"During `GenerateTag`, a component tagger (e.g. GIT, SHA, DIGEST) errors — e.g. `git describe` fails because the workspace is not a git repo, or digest computation fails because the image isn't available.","commonSituations":"GIT component used outside a git repository or with no commits; SHA/digest tagger used before the image is built/pushed; git binary missing in the environment; shallow clone without tags.","solutions":["Read the wrapped cause to identify which component failed and why","For GIT component: ensure the workspace is a git repo with at least one commit (git init && git commit)","For DIGEST/SHA components: ensure the image was built/pushed before tagging","Verify git is installed and accessible on PATH"],"exampleFix":"// before: not a git repo, GIT tagger fails\nskaffold dev\n// after\ngit init && git add -A && git commit -m init\nskaffold dev","handlingStrategy":"try-catch","validationCode":"// pre-check environment for GIT component\nif fieldsContain(tmpl, \"GIT\") {\n    if _, err := exec.LookPath(\"git\"); err != nil {\n        return errors.New(\"git not on PATH; required by GIT tag component\")\n    }\n    if _, err := git.ExecCommand(ctx, nil, \"rev-parse\", \"HEAD\"); err != nil {\n        return errors.New(\"not a git repository with commits\")\n    }\n}","typeGuard":null,"tryCatchPattern":"customMap, err := tag.EvaluateComponents(ctx, t, image)\nif err != nil {\n    var cause error\n    if errors.As(err, &cause) {\n        log.Errorf(\"component failed: %v\", cause) // e.g. git describe error\n    }\n    return fmt.Errorf(\"ensure git repo exists and image is built: %w\", err)\n}","preventionTips":["git init + initial commit before skaffold dev in new projects","Install git in CI images","Build/push images before tags depending on DIGEST/SHA","Avoid shallow clones when tags are needed"],"tags":["tagging","templating","git"],"backgroundTag":"tag-generation-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"}