GoogleContainerTools/skaffold · error

parsing template: %w

Error message

parsing template: %w

What it means

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.

Source

Thrown at pkg/skaffold/tag/custom_template.go:42

	"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/graph"
	"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/output/log"
	"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/runner/runcontext"
	"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest"
)

// customTemplateTagger implements Tagger
type customTemplateTagger struct {
	RunCtx     *runcontext.RunContext
	Template   *template.Template
	Components map[string]Tagger
}

// NewCustomTemplateTagger creates a new customTemplateTagger
func NewCustomTemplateTagger(runCtx *runcontext.RunContext, t string, components map[string]Tagger) (Tagger, error) {
	tmpl, err := ParseCustomTemplate(t)
	if err != nil {
		return nil, fmt.Errorf("parsing template: %w", err)
	}

	return &customTemplateTagger{
		RunCtx:     runCtx,
		Template:   tmpl,
		Components: components,
	}, nil
}

// GenerateTag generates a tag from a template referencing tagging strategies.
func (t *customTemplateTagger) GenerateTag(ctx context.Context, image latest.Artifact) (string, error) {
	customMap, err := t.EvaluateComponents(ctx, image)
	if err != nil {
		return "", err
	}

	// missingkey=error throws error when map is indexed with an undefined key
	tag, err := ExecuteCustomTemplate(t.Template.Option("missingkey=error"), customMap)

View on GitHub (pinned to a1189de023)

Solutions

  1. Fix the template syntax — must be valid Go text/template, e.g. `{{.SHA}}`
  2. Check the wrapped cause for the exact parse position reported by text/template
  3. Validate components used are supported (DATE, SHA, GIT, etc.)
  4. Quote the template properly in YAML (use single quotes or block scalar)

Example fix

// before (skaffold.yaml)
tagger:
  customTemplate: "{{DATE}-{{.SHA}}"
// after
tagger:
  customTemplate: "{{.DATE}}-{{.SHA}}"
Defensive patterns

Strategy: validation

Validate before calling

// validate template before handing to NewCustomTemplateTagger
if _, err := template.New("t").Parse("{{.DATE}}-{{.SHA}}" /* your template */); err != nil {
    return fmt.Errorf("invalid customTemplate: %w", err)
}
if _, err := tag.ParseCustomTemplate(cfg.Build.Taggers.CustomTemplate.Template); err != nil {
    return fmt.Errorf("skaffold.yaml customTemplate invalid: %w", err)
}

Try / catch

tagger, err := tag.NewCustomTemplateTagger(runCtx, tmpl, components)
if err != nil {
    if strings.Contains(err.Error(), "parsing template") {
        return fmt.Errorf("check customTemplate syntax in skaffold.yaml: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: `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.

Common situations: Typo like `{{DATE}` (missing brace); using unsupported Go template constructs; stray `%` or malformed pipeline; copy-pasted template from docs with wrong quoting in YAML.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/69c943322cd23796. Report an issue: GitHub.