GoogleContainerTools/skaffold · error
invalid build dependency for artifact %q: alias %q repeated
Error message
invalid build dependency for artifact %q: alias %q repeated
What it means
validateUniqueDependencyAliases ensures each artifact's build dependency aliases are unique. Duplicate aliases would create an ambiguous mapping when Skaffold injects dependency images into the Dockerfile ARGs or custom environment, so the second occurrence fails validation.
Source
Thrown at pkg/skaffold/schema/validation/validation.go:294
}
}
return
}
// validateUniqueDependencyAliases makes sure that artifact dependency aliases are unique for each artifact
func validateUniqueDependencyAliases(cfgs *parser.SkaffoldConfigSet, artifacts []*latest.Artifact) (cfgErrs []ErrorWithLocation) {
type State int
var (
unseen State = 0
seen State = 1
recorded State = 2
)
for i, a := range artifacts {
aliasMap := make(map[string]State)
for j, d := range a.Dependencies {
if aliasMap[d.Alias] == seen {
cfgErrs = append(cfgErrs, ErrorWithLocation{
Error: fmt.Errorf("invalid build dependency for artifact %q: alias %q repeated", a.ImageName, d.Alias),
Location: cfgs.LocateField(artifacts[i].Dependencies[j], "Alias"),
})
aliasMap[d.Alias] = recorded
} else if aliasMap[d.Alias] == unseen {
aliasMap[d.Alias] = seen
}
}
}
return
}
// extractContainerNameFromNetworkMode returns the container name even if it comes from an Env Var. Error if the mode isn't valid
// (only container:<id|name> format allowed)
func extractContainerNameFromNetworkMode(mode string) (string, error) {
if strings.HasPrefix(strings.ToLower(mode), "container:") {
// Up to this point, we know that we can strip until the colon symbol and keep the second part
// this is helpful in case someone sends container not in lowercase
maybeID := strings.SplitN(mode, ":", 2)[1]View on GitHub (pinned to a1189de023)
Solutions
- Give each dependency of that artifact a distinct alias
- Remove the duplicate requires entry if it was accidentally duplicated
- Update Dockerfile ARG / script env references to the new unique alias names
Example fix
// before
- image: app
requires:
- image: base
alias: base
- image: sidecar
alias: base
// after
- image: app
requires:
- image: base
alias: base
- image: sidecar
alias: sidecar Defensive patterns
Strategy: validation
Validate before calling
// Go: aliases must be unique per artifact
func duplicateAliases(deps []string) []string {
seen := map[string]bool{}
var dups []string
for _, a := range deps {
if seen[a] {
dups = append(dups, a)
}
seen[a] = true
}
return dups
} Try / catch
if dups := duplicateAliases(aliases); len(dups) > 0 {
return fmt.Errorf("duplicate dependency aliases: %v", dups)
} Prevention
- Name each alias after its dependency image to keep them naturally unique
- Review requires blocks after copy-pasting entries
- Add a lint check that asserts per-artifact alias uniqueness
When it happens
Trigger: One artifact lists two buildDependencies entries with the same alias value, detected when aliasMap[d.Alias] is already 'seen' in validateUniqueDependencyAliases.
Common situations: Copy-pasting a requires block and forgetting to change the alias, or two dependencies on different images given the same alias name.
Related errors
- invalid build dependency for artifact %q: alias %q doesn't m
- cycle detected in build dependencies involving %q
- unknown build dependency %q for artifact %q
- `apply` requires at least one manifest argument
- `exec` requires exactly one action to execute
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/f3db616bf9d8f303.
Report an issue: GitHub.