{"record":{"id":"69c943322cd23796","repo":"GoogleContainerTools/skaffold","slug":"parsing-template-w","errorCode":null,"errorMessage":"parsing template: %w","messagePattern":"parsing template: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/tag/custom_template.go","lineNumber":42,"sourceCode":"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/graph\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/output/log\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/runner/runcontext\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest\"\n)\n\n// customTemplateTagger implements Tagger\ntype customTemplateTagger struct {\n\tRunCtx     *runcontext.RunContext\n\tTemplate   *template.Template\n\tComponents map[string]Tagger\n}\n\n// NewCustomTemplateTagger creates a new customTemplateTagger\nfunc NewCustomTemplateTagger(runCtx *runcontext.RunContext, t string, components map[string]Tagger) (Tagger, error) {\n\ttmpl, err := ParseCustomTemplate(t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing template: %w\", err)\n\t}\n\n\treturn &customTemplateTagger{\n\t\tRunCtx:     runCtx,\n\t\tTemplate:   tmpl,\n\t\tComponents: components,\n\t}, nil\n}\n\n// GenerateTag generates a tag from a template referencing tagging strategies.\nfunc (t *customTemplateTagger) GenerateTag(ctx context.Context, image latest.Artifact) (string, error) {\n\tcustomMap, err := t.EvaluateComponents(ctx, image)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// missingkey=error throws error when map is indexed with an undefined key\n\ttag, err := ExecuteCustomTemplate(t.Template.Option(\"missingkey=error\"), customMap)","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/tag/custom_template.go#L24-L60","documentation":"The custom tag template string could not be parsed by Go's text/template engine. `NewCustomTemplateTagger` calls `ParseCustomTemplate(t)`, which validates the template syntax; a syntax error is wrapped here. The tagger is not constructed, so tagging aborts.","triggerScenarios":"`skaffold.yaml` sets a custom tagger template (e.g. `tagger.customTemplate: \"{{DATE}}-{{.SHA}}\"`) containing invalid template syntax, unknown functions, or unbalanced braces; `getTagger` invokes `NewCustomTemplateTagger` which returns this error.","commonSituations":"Typo like `{{DATE}` (missing brace); using unsupported Go template constructs; stray `%` or malformed pipeline; copy-pasted template from docs with wrong quoting in YAML.","solutions":["Fix the template syntax — must be valid Go text/template, e.g. `{{.SHA}}`","Check the wrapped cause for the exact parse position reported by text/template","Validate components used are supported (DATE, SHA, GIT, etc.)","Quote the template properly in YAML (use single quotes or block scalar)"],"exampleFix":"// before (skaffold.yaml)\ntagger:\n  customTemplate: \"{{DATE}-{{.SHA}}\"\n// after\ntagger:\n  customTemplate: \"{{.DATE}}-{{.SHA}}\"","handlingStrategy":"validation","validationCode":"// validate template before handing to NewCustomTemplateTagger\nif _, err := template.New(\"t\").Parse(\"{{.DATE}}-{{.SHA}}\" /* your template */); err != nil {\n    return fmt.Errorf(\"invalid customTemplate: %w\", err)\n}\nif _, err := tag.ParseCustomTemplate(cfg.Build.Taggers.CustomTemplate.Template); err != nil {\n    return fmt.Errorf(\"skaffold.yaml customTemplate invalid: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"tagger, err := tag.NewCustomTemplateTagger(runCtx, tmpl, components)\nif err != nil {\n    if strings.Contains(err.Error(), \"parsing template\") {\n        return fmt.Errorf(\"check customTemplate syntax in skaffold.yaml: %w\", err)\n    }\n    return err\n}","preventionTips":["Test templates with `skaffold build --tag` before CI","Remember fields use dot syntax: {{.SHA}}, not {{SHA}}","Quote templates safely in YAML single quotes","Keep only supported components in the template"],"tags":["templating","configuration","tagging"],"backgroundTag":"template-parse-error","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"}