{"record":{"id":"e0e7c865b8441ef5","repo":"kubernetes/kops","slug":"unhandled-field-q-e0e7c8","errorCode":null,"errorMessage":"unhandled field: %q","messagePattern":"unhandled field: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/set_instancegroups.go","lineNumber":32,"sourceCode":"limitations under the License.\n*/\n\npackage commands\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\n\tapi \"k8s.io/kops/pkg/apis/kops\"\n\t\"k8s.io/kops/util/pkg/reflectutils\"\n)\n\n// SetInstancegroupFields sets field values in the instance group.\nfunc SetInstancegroupFields(fields []string, instanceGroup *api.InstanceGroup) error {\n\tfor _, field := range fields {\n\t\tkv := strings.SplitN(field, \"=\", 2)\n\t\tif len(kv) != 2 {\n\t\t\treturn fmt.Errorf(\"unhandled field: %q\", field)\n\t\t}\n\n\t\tkey := kv[0]\n\t\tkey = strings.TrimPrefix(key, \"instancegroup.\")\n\n\t\tif err := reflectutils.SetString(instanceGroup, key, kv[1]); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":14,"sourceCodeEnd":45,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/commands/set_instancegroups.go#L14-L45","documentation":"SetInstancegroupFields requires each field in key=value form; a field without '=' makes strings.SplitN return one element and the function returns 'unhandled field: %q'. Same strict parser as SetClusterFields but for instance group fields.","triggerScenarios":"Calling SetInstancegroupFields with entries like \"spec.machineType\" (no '=value'), e.g. a malformed --set on `kops edit ig`. TestSetInstanceGroupsBadInput covers this case.","commonSituations":"Omitting the value in shell scripting loops; copy-pasting kubectl label syntax; forgetting the instancegroup. prefix handling where key is trimmed before SetString.","solutions":["Format every field as key=value, e.g. instancegroup.spec.machineType=t3.medium.","Quote arguments containing spaces or ranges.","Check the loop/script generating the fields array for empty or truncated entries."],"exampleFix":"// before\nfields := []string{\"spec.machineType\"}\nerr := SetInstancegroupFields(fields, ig) // unhandled field: \"spec.machineType\"\n// after\nfields := []string{\"spec.machineType=t3.medium\"}\nerr := SetInstancegroupFields(fields, ig)","handlingStrategy":"validation","validationCode":"func validIGFields(fields []string) error {\n\tfor _, f := range fields {\n\t\tif !strings.Contains(f, \"=\") {\n\t\t\treturn fmt.Errorf(\"instance group field %q must be key=value\", f)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isKeyValue(s string) bool {\n\tparts := strings.SplitN(s, \"=\", 2)\n\treturn len(parts) == 2 && parts[0] != \"\"\n}","tryCatchPattern":"if err := SetInstancegroupFields(fields, instanceGroup); err != nil {\n\tif strings.HasPrefix(err.Error(), \"unhandled field:\") {\n\t\treturn fmt.Errorf(\"each field needs key=value form; got %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Validate user-supplied --set strings before invoking the setter.","Quote arguments containing '=' or spaces in shell scripts.","Mirror the TestSetInstanceGroupsBadInput test in your own tooling.","Document the key=value syntax wherever the CLI is invoked from automation."],"tags":["kops","instance-group","argument-parsing"],"backgroundTag":"invalid-key-value-field-syntax","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}