{"record":{"id":"934739091dc95041","repo":"GoogleContainerTools/skaffold","slug":"config-duplicate-names-same-file-err","errorCode":"CONFIG_DUPLICATE_NAMES_SAME_FILE_ERR","errorMessage":"multiple skaffold configs named %q found in file %q","messagePattern":"multiple skaffold configs named %q found in file %q","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/schema/errors/errors.go","lineNumber":95,"sourceCode":"\t\t\t\t},\n\t\t\t},\n\t\t})\n}\n\n// ZeroConfigsParsedErr specifies that the config file is empty\nfunc ZeroConfigsParsedErr(file string) error {\n\tmsg := fmt.Sprintf(\"failed to get any valid configs from file %q\", file)\n\treturn sErrors.NewError(errors.New(msg),\n\t\t&proto.ActionableErr{\n\t\t\tMessage: msg,\n\t\t\tErrCode: proto.StatusCode_CONFIG_ZERO_FOUND_ERR,\n\t\t})\n}\n\n// DuplicateConfigNamesInSameFileErr specifies that multiple configs have the same name in current config file\nfunc DuplicateConfigNamesInSameFileErr(config, file string) error {\n\tmsg := fmt.Sprintf(\"multiple skaffold configs named %q found in file %q\", config, file)\n\treturn sErrors.NewError(errors.New(msg),\n\t\t&proto.ActionableErr{\n\t\t\tMessage: msg,\n\t\t\tErrCode: proto.StatusCode_CONFIG_DUPLICATE_NAMES_SAME_FILE_ERR,\n\t\t\tSuggestions: []*proto.Suggestion{\n\t\t\t\t{\n\t\t\t\t\tSuggestionCode: proto.SuggestionCode_CONFIG_CHANGE_NAMES,\n\t\t\t\t\tAction:         fmt.Sprintf(\"Change the name of one of the occurrences of config %q in file %q to make it unique\", config, file),\n\t\t\t\t},\n\t\t\t},\n\t\t})\n}\n\n// DuplicateConfigNamesAcrossFilesErr specifies that multiple configs have the same name in different files\nfunc DuplicateConfigNamesAcrossFilesErr(config, file1, file2 string) error {\n\tmsg := fmt.Sprintf(\"skaffold config named %q found in multiple files: %q and %q\", config, file1, file2)\n\treturn sErrors.NewError(errors.New(msg),\n\t\t&proto.ActionableErr{\n\t\t\tMessage: msg,","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/schema/errors/errors.go#L77-L113","documentation":"DuplicateConfigNamesInSameFileErr fires when two configurations inside the same file share the same `metadata.name`. Named configs must be unique within a file so cross-file dependency resolution can address them unambiguously. Code CONFIG_DUPLICATE_NAMES_SAME_FILE_ERR with suggestion CONFIG_CHANGE_NAMES.","triggerScenarios":"Parsing a multi-document skaffold.yaml where two `kind: Config` documents both define the same `metadata.name`, then resolving configs by name.","commonSituations":"Copy-pasting a config document into the same file to create a variant (e.g. staging/prod) but forgetting to rename `metadata.name`.","solutions":["Rename one of the duplicate configs' `metadata.name` to a unique value.","Merge the two documents into one if they are meant to be the same config.","Move the second variant into a separate file if it is intentionally a distinct config."],"exampleFix":"// before (two docs in one file)\nmetadata:\n  name: my-app\n---\nmetadata:\n  name: my-app\n// after\nmetadata:\n  name: my-app\n---\nmetadata:\n  name: my-app-staging","handlingStrategy":"validation","validationCode":"yq e 'select(documentIndex > 0)' -N skaffold.yaml 2>/dev/null\n# or in CI: assert metadata.name values across all YAML docs are unique\nnames=$(yq e '.metadata.name // \"\"' skaffold.yaml | sort | uniq -d); test -z \"$names\" || echo \"duplicates: $names\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When duplicating a config document to create a variant, immediately rename metadata.name.","Add a CI lint step that checks metadata.name uniqueness per file.","Prefer profiles for variants instead of duplicating whole config documents."],"tags":["config","naming","yaml"],"backgroundTag":"duplicate-config-name","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"}