{"record":{"id":"ca89e86972f1fffd","repo":"GoogleContainerTools/skaffold","slug":"only-one-element-in-set-s-can-be-set-got-s-and","errorCode":null,"errorMessage":"only one element in set %s can be set. got %s and %s","messagePattern":"only one element in set (.+?) can be set\\. got (.+?) and (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/yamltags/tags.go","lineNumber":235,"sourceCode":"\t}\n\toot.oneOfSets[oot.setName][oot.Field.Name] = struct{}{}\n\treturn nil\n}\n\nfunc (oot *oneOfTag) Process(val reflect.Value) error {\n\tif isZeroValue(val) {\n\t\treturn nil\n\t}\n\n\t// This must exist because process is always called after Load.\n\toneOfSet := oot.oneOfSets[oot.setName]\n\tfor otherField := range oneOfSet {\n\t\tif otherField == oot.Field.Name {\n\t\t\tcontinue\n\t\t}\n\t\tfield := oot.Parent.FieldByName(otherField)\n\t\tif !isZeroValue(field) {\n\t\t\treturn fmt.Errorf(\"only one element in set %s can be set. got %s and %s\", oot.setName, otherField, oot.Field.Name)\n\t\t}\n\t}\n\treturn nil\n}\n\ntype skipTrimTag struct {\n\tField reflect.StructField\n}\n\nfunc (tag *skipTrimTag) Load(s []string) error {\n\treturn nil\n}\n\nfunc (tag *skipTrimTag) Process(val reflect.Value) error {\n\tif isZeroValue(val) {\n\t\tif tags, ok := tag.Field.Tag.Lookup(\"yaml\"); ok {\n\t\t\treturn fmt.Errorf(\"skipTrim value not set: %s\", strings.Split(tags, \",\")[0])\n\t\t}","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/yamltags/tags.go#L217-L253","documentation":"For fields in a oneOf set (mutually exclusive config alternatives), oneOfTag.Process verifies no sibling field of the same set is also non-zero. If two members are set (e.g. both `docker` and `kaniko` build strategies, or two execution modes), it returns 'only one element in set %s can be set', naming the set and the two conflicting fields.","triggerScenarios":"A decoded skaffold.yaml supplies values for two fields that belong to the same oneOf set on a struct (e.g. both `exec` and `docker` in a build execution environment, or both `docker` and `kubernetesCluster` execution modes for verify), then validation runs.","commonSituations":"Merging config files/snippets and keeping both alternatives; leftover key from a previous strategy plus a newly added one; auto-generated config setting defaults alongside user overrides.","solutions":["Remove one of the two fields named in the error from skaffold.yaml, keeping the alternative you intend","Comment out the unused strategy block rather than leaving empty-looking keys that may parse as set","Use `skaffold fix` or `skaffold init` to regenerate a valid single-choice config","Check indentation — a misnested key can accidentally land in the sibling field's position"],"exampleFix":"// before (skaffold.yaml) — both set\nbuild:\n  artifacts:\n    - image: foo\n  kaniko: {}\n  docker: {}\n// after\nbuild:\n  artifacts:\n    - image: foo\n  docker: {}","handlingStrategy":"validation","validationCode":"// ensure only one member of a oneOf set is present in the decoded config\nfunc oneOfSet(m map[string]interface{}, members []string) error {\n    var set []string\n    for _, k := range members {\n        if v, ok := m[k]; ok && v != nil && v != \"\" {\n            set = append(set, k)\n        }\n    }\n    if len(set) > 1 {\n        return fmt.Errorf(\"only one of %v can be set; got %v\", members, set)\n    }\n    return nil\n}","typeGuard":"func exactlyOneSet(flags ...bool) bool {\n    n := 0\n    for _, f := range flags { if f { n++ } }\n    return n == 1\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"only one element in set\") {\n    // parse set + two field names from the message, drop the unwanted one from config\n}","preventionTips":["Keep only one strategy block (e.g. one executionMode / one build env) in skaffold.yaml","Comment out unused alternative blocks entirely when switching strategies","Validate merged config files for duplicate alternatives before applying","Use `skaffold init` to regenerate clean single-choice configs"],"tags":["config-validation","yaml","mutually-exclusive"],"backgroundTag":"mutually-exclusive-fields-set","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"}