GoogleContainerTools/skaffold · error

multiple components with name %s

Error message

multiple components with name %s

What it means

CreateComponents iterates tagPolicy.customTemplate.components and stores each tagger in a map keyed by component name. If two components share the same name the second would silently overwrite the first (or break template references), so Skaffold rejects the configuration with this error.

Source

Thrown at pkg/skaffold/tag/tagger_mux.go:100

			return nil, fmt.Errorf("creating components: %w", err)
		}

		return NewCustomTemplateTagger(runCtx, t.CustomTemplateTagger.Template, components)

	default:
		return nil, fmt.Errorf("unknown tagger for strategy %+v", t)
	}
}

// CreateComponents creates a map of taggers for CustomTemplateTagger
func CreateComponents(runCtx *runcontext.RunContext, t *latest.CustomTemplateTagger) (map[string]Tagger, error) {
	components := map[string]Tagger{}

	for _, taggerComponent := range t.Components {
		name, c := taggerComponent.Name, taggerComponent.Component

		if _, ok := components[name]; ok {
			return nil, fmt.Errorf("multiple components with name %s", name)
		}

		switch {
		case c.EnvTemplateTagger != nil:
			components[name], _ = NewEnvTemplateTagger(c.EnvTemplateTagger.Template)

		case c.ShaTagger != nil:
			components[name] = &ChecksumTagger{}

		case c.GitTagger != nil:
			components[name], _ = NewGitCommit(c.GitTagger.Prefix, c.GitTagger.Variant, c.GitTagger.IgnoreChanges)

		case c.DateTimeTagger != nil:
			components[name] = NewDateTimeTagger(c.DateTimeTagger.Format, c.DateTimeTagger.TimeZone)

		case c.InputDigest != nil:
			graph := graph.ToArtifactGraph(runCtx.Artifacts())
			inputDigest, _ := NewInputDigestTagger(runCtx, graph)

View on GitHub (pinned to a1189de023)

Solutions

  1. Rename one of the duplicate components to a unique name
  2. Update the customTemplate template string to reference the new name
  3. Deduplicate the components list in skaffold.yaml

Example fix

// before
components:
  - name: SHA
    sha256: {}
  - name: SHA
    gitCommit: {}

// after
components:
  - name: SHA
    sha256: {}
  - name: GIT
    gitCommit: {}
Defensive patterns

Strategy: validation

Validate before calling

seen := map[string]bool{}
for _, c := range tp.CustomTemplateTagger.Components {
    if seen[c.Name] {
        return fmt.Errorf("duplicate component name %q", c.Name)
    }
    seen[c.Name] = true
}

Try / catch

t, err := tag.NewTaggerMux(runCtx)
if err != nil && strings.Contains(err.Error(), "multiple components with name") {
    return fmt.Errorf("fix tagPolicy.customTemplate component names: %w", err)
}

Prevention

When it happens

Trigger: A customTemplate tag policy whose components array contains two or more entries with the same `name` value, encountered when getTagger calls CreateComponents.

Common situations: Copy-pasting a component block and forgetting to rename it; generating components programmatically with a collision; merging YAML across profiles so duplicate name keys survive.

Related errors


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