{"record":{"id":"1ccb60415b9336e4","repo":"GoogleContainerTools/skaffold","slug":"parsing-template-w-1ccb60","errorCode":null,"errorMessage":"parsing template: %w","messagePattern":"parsing template: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/tag/env_template.go","lineNumber":38,"sourceCode":"\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\t\"text/template\"\n\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util\"\n)\n\n// envTemplateTagger implements Tagger\ntype envTemplateTagger struct {\n\tTemplate *template.Template\n}\n\n// NewEnvTemplateTagger creates a new envTemplateTagger\nfunc NewEnvTemplateTagger(t string) (Tagger, error) {\n\ttmpl, err := util.ParseEnvTemplate(t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing template: %w\", err)\n\t}\n\n\treturn &envTemplateTagger{\n\t\tTemplate: tmpl,\n\t}, nil\n}\n\n// GenerateTag generates a tag from a template referencing environment variables.\nfunc (t *envTemplateTagger) GenerateTag(ctx context.Context, image latest.Artifact) (string, error) {\n\t// The method with missingkey=invalid option does not fail if the referenced variable does not exist in the map.\n\t// It will be replaced by <no value> if no other Go template method handles the missing key.\n\t// This gives us an opportunity to handle missing keys with other Go template methods. For example, the default method\n\t// can be used to set a default value for a missing key. The evaluation of {{default \"bar\" .FOO}} should be \"bar\" and\n\t// tagging should succeed if the environment variable .FOO does not exist.\n\ttag, err := util.ExecuteEnvTemplate(t.Template.Option(\"missingkey=invalid\"), map[string]string{\n\t\t\"IMAGE_NAME\": image.ImageName,\n\t})\n\tif err != nil {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/tag/env_template.go#L20-L56","documentation":"NewEnvTemplateTagger wraps the envTemplateTagger construction; the template string from skaffold.yaml is parsed with util.ParseEnvTemplate (Go text/template). If the template has invalid syntax (unclosed actions, bad pipes, stray braces), construction fails and the parse error is wrapped with 'parsing template:'.","triggerScenarios":"Calling NewEnvTemplateTagger(\"{{ .IMAGE }}\") or configuring tagger.env_Template.template_Template with malformed Go template syntax such as '{{ FOO' (missing closing braces) or '{{ .FOO | badFunc }}'.","commonSituations":"Hand-editing skaffold.yaml and leaving an unclosed {{ or using shell-style $VAR syntax instead of Go template syntax; quoting issues in YAML mangling the template string.","solutions":["Fix the Go template syntax in skaffold.yaml (every {{ }} must be closed and use valid template constructs)","Test the template standalone with text/template in Go or `go run` to see the exact parse position","Use '{{.FOO}}' env-template form (no custom funcs) — unsupported functions also fail parsing","Validate skaffold.yaml with `skaffold config` / `skaffold build --dry-run` before running builds"],"exampleFix":"// before\nNewEnvTemplateTagger(\"{{ .TAG }}-{{ DATE }\")\n// after\nNewEnvTemplateTagger(\"{{ .TAG }}-{{ .DATE }}\")","handlingStrategy":"validation","validationCode":"if _, err := template.New(\"t\").Parse(cfg.Template); err != nil {\n    return fmt.Errorf(\"invalid env template %q: %w\", cfg.Template, err)\n}","typeGuard":null,"tryCatchPattern":"tagger, err := tag.NewEnvTemplateTagger(tmpl)\nif err != nil {\n    return fmt.Errorf(\"configuring env template tagger: %w\", err)\n}","preventionTips":["Use valid Go text/template syntax ({{ .VAR }}), not shell $VAR","Close every {{ with }}","Validate templates in a unit test or with a quick Go snippet","Use IDE schema validation for skaffold.yaml"],"tags":["go","skaffold","template","configuration","tagging"],"backgroundTag":"template-syntax-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"}