{"record":{"id":"f3db616bf9d8f303","repo":"GoogleContainerTools/skaffold","slug":"invalid-build-dependency-for-artifact-q-alias-q-f3db61","errorCode":null,"errorMessage":"invalid build dependency for artifact %q: alias %q repeated","messagePattern":"invalid build dependency for artifact %q: alias %q repeated","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/schema/validation/validation.go","lineNumber":294,"sourceCode":"\t\t}\n\t}\n\treturn\n}\n\n// validateUniqueDependencyAliases makes sure that artifact dependency aliases are unique for each artifact\nfunc validateUniqueDependencyAliases(cfgs *parser.SkaffoldConfigSet, artifacts []*latest.Artifact) (cfgErrs []ErrorWithLocation) {\n\ttype State int\n\tvar (\n\t\tunseen   State = 0\n\t\tseen     State = 1\n\t\trecorded State = 2\n\t)\n\tfor i, a := range artifacts {\n\t\taliasMap := make(map[string]State)\n\t\tfor j, d := range a.Dependencies {\n\t\t\tif aliasMap[d.Alias] == seen {\n\t\t\t\tcfgErrs = append(cfgErrs, ErrorWithLocation{\n\t\t\t\t\tError:    fmt.Errorf(\"invalid build dependency for artifact %q: alias %q repeated\", a.ImageName, d.Alias),\n\t\t\t\t\tLocation: cfgs.LocateField(artifacts[i].Dependencies[j], \"Alias\"),\n\t\t\t\t})\n\t\t\t\taliasMap[d.Alias] = recorded\n\t\t\t} else if aliasMap[d.Alias] == unseen {\n\t\t\t\taliasMap[d.Alias] = seen\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\n// extractContainerNameFromNetworkMode returns the container name even if it comes from an Env Var. Error if the mode isn't valid\n// (only container:<id|name> format allowed)\nfunc extractContainerNameFromNetworkMode(mode string) (string, error) {\n\tif strings.HasPrefix(strings.ToLower(mode), \"container:\") {\n\t\t// Up to this point, we know that we can strip until the colon symbol and keep the second part\n\t\t// this is helpful in case someone sends container not in lowercase\n\t\tmaybeID := strings.SplitN(mode, \":\", 2)[1]","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/schema/validation/validation.go#L276-L312","documentation":"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.","triggerScenarios":"One artifact lists two buildDependencies entries with the same alias value, detected when aliasMap[d.Alias] is already 'seen' in validateUniqueDependencyAliases.","commonSituations":"Copy-pasting a requires block and forgetting to change the alias, or two dependencies on different images given the same alias name.","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"],"exampleFix":"// before\n- image: app\n  requires:\n    - image: base\n      alias: base\n    - image: sidecar\n      alias: base\n// after\n- image: app\n  requires:\n    - image: base\n      alias: base\n    - image: sidecar\n      alias: sidecar","handlingStrategy":"validation","validationCode":"// Go: aliases must be unique per artifact\nfunc duplicateAliases(deps []string) []string {\n\tseen := map[string]bool{}\n\tvar dups []string\n\tfor _, a := range deps {\n\t\tif seen[a] {\n\t\t\tdups = append(dups, a)\n\t\t}\n\t\tseen[a] = true\n\t}\n\treturn dups\n}","typeGuard":null,"tryCatchPattern":"if dups := duplicateAliases(aliases); len(dups) > 0 {\n\treturn fmt.Errorf(\"duplicate dependency aliases: %v\", dups)\n}","preventionTips":["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"],"tags":["skaffold","build-dependencies","alias","duplicate"],"backgroundTag":"duplicate-dependency-alias","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"}