{"record":{"id":"efd53e05e926acb1","repo":"GoogleContainerTools/skaffold","slug":"invalid-build-dependency-for-artifact-q-alias-q","errorCode":null,"errorMessage":"invalid build dependency for artifact %q: alias %q doesn't match required pattern %q","messagePattern":"invalid build dependency for artifact %q: alias %q doesn't match required pattern %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/schema/validation/validation.go","lineNumber":272,"sourceCode":"\t\t}\n\t\tif err := dfs(d, visited, marked, artifacts); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\n// validateValidDependencyAliases makes sure that artifact dependency aliases are valid.\n// docker and custom builders require aliases match [a-zA-Z_][a-zA-Z0-9_]* pattern\nfunc validateValidDependencyAliases(cfgs *parser.SkaffoldConfigSet, artifacts []*latest.Artifact) (cfgErrs []ErrorWithLocation) {\n\tfor i, a := range artifacts {\n\t\tif a.DockerArtifact == nil && a.CustomArtifact == nil {\n\t\t\tcontinue\n\t\t}\n\t\tfor j, d := range a.Dependencies {\n\t\t\tif !dependencyAliasPattern.MatchString(d.Alias) {\n\t\t\t\tcfgErrs = append(cfgErrs, ErrorWithLocation{\n\t\t\t\t\tError:    fmt.Errorf(\"invalid build dependency for artifact %q: alias %q doesn't match required pattern %q\", a.ImageName, d.Alias, dependencyAliasPattern.String()),\n\t\t\t\t\tLocation: cfgs.LocateField(artifacts[i].Dependencies[j], \"Alias\"),\n\t\t\t\t})\n\t\t\t}\n\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)","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/schema/validation/validation.go#L254-L290","documentation":"validateValidDependencyAliases enforces that docker and custom artifact dependency aliases match the pattern [a-zA-Z_][a-zA-Z0-9_]*. Aliases are substituted into Dockerfile ARGs / custom script env vars, so they must be valid shell-style identifiers.","triggerScenarios":"A docker or custom artifact has buildDependencies[].alias containing dashes, dots, a leading digit, or other characters outside the identifier pattern, checked via dependencyAliasPattern.MatchString.","commonSituations":"Using the image name verbatim ('my-app/api') as an alias, or hyphenated names like 'base-image' that are invalid shell identifiers.","solutions":["Rename the alias to match [a-zA-Z_][a-zA-Z0-9_]*, e.g. 'base_image' instead of 'base-image'","Update the matching ARG name in the Dockerfile (or env var in the custom script) to the new alias","Start the alias with a letter or underscore, never a digit"],"exampleFix":"// before\n- image: app\n  requires:\n    - image: base-image\n      alias: base-image\n// after\n- image: app\n  requires:\n    - image: base-image\n      alias: base_image","handlingStrategy":"validation","validationCode":"// Go: alias must match [a-zA-Z_][a-zA-Z0-9_]*\nvar aliasRe = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_]*$`)\nfunc validAlias(alias string) bool { return aliasRe.MatchString(alias) }","typeGuard":null,"tryCatchPattern":"if !validAlias(alias) {\n\treturn fmt.Errorf(\"alias %q must match [a-zA-Z_][a-zA-Z0-9_]*\", alias)\n}","preventionTips":["Use snake_case aliases; never include hyphens, dots, or leading digits","Keep alias identical to the ARG name in the Dockerfile","Add a YAML lint rule checking aliases against the pattern"],"tags":["skaffold","build-dependencies","alias","docker"],"backgroundTag":"invalid-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"}