GoogleContainerTools/skaffold · error
parsing template: %w
Error message
parsing template: %w
What it means
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:'.
Source
Thrown at pkg/skaffold/tag/env_template.go:38
"context"
"fmt"
"strings"
"text/template"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util"
)
// envTemplateTagger implements Tagger
type envTemplateTagger struct {
Template *template.Template
}
// NewEnvTemplateTagger creates a new envTemplateTagger
func NewEnvTemplateTagger(t string) (Tagger, error) {
tmpl, err := util.ParseEnvTemplate(t)
if err != nil {
return nil, fmt.Errorf("parsing template: %w", err)
}
return &envTemplateTagger{
Template: tmpl,
}, nil
}
// GenerateTag generates a tag from a template referencing environment variables.
func (t *envTemplateTagger) GenerateTag(ctx context.Context, image latest.Artifact) (string, error) {
// The method with missingkey=invalid option does not fail if the referenced variable does not exist in the map.
// It will be replaced by <no value> if no other Go template method handles the missing key.
// This gives us an opportunity to handle missing keys with other Go template methods. For example, the default method
// can be used to set a default value for a missing key. The evaluation of {{default "bar" .FOO}} should be "bar" and
// tagging should succeed if the environment variable .FOO does not exist.
tag, err := util.ExecuteEnvTemplate(t.Template.Option("missingkey=invalid"), map[string]string{
"IMAGE_NAME": image.ImageName,
})
if err != nil {View on GitHub (pinned to a1189de023)
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
Example fix
// before
NewEnvTemplateTagger("{{ .TAG }}-{{ DATE }")
// after
NewEnvTemplateTagger("{{ .TAG }}-{{ .DATE }}") Defensive patterns
Strategy: validation
Validate before calling
if _, err := template.New("t").Parse(cfg.Template); err != nil {
return fmt.Errorf("invalid env template %q: %w", cfg.Template, err)
} Try / catch
tagger, err := tag.NewEnvTemplateTagger(tmpl)
if err != nil {
return fmt.Errorf("configuring env template tagger: %w", err)
} Prevention
- 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
When it happens
Trigger: Calling NewEnvTemplateTagger("{{ .IMAGE }}") or configuring tagger.env_Template.template_Template with malformed Go template syntax such as '{{ FOO' (missing closing braces) or '{{ .FOO | badFunc }}'.
Common situations: 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.
Related errors
- bad timezone provided: %q, error: %s
- environment variables missing for template keys
- %q is not a valid git tagger variant
- unable to find git commit: %w
- getting git status: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/1ccb60415b9336e4.
Report an issue: GitHub.