{"record":{"id":"96876e3fa401436d","repo":"kubernetes/kops","slug":"unhandled-type-q","errorCode":null,"errorMessage":"unhandled type %q","messagePattern":"unhandled type %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/reflectutils/access.go","lineNumber":181,"sourceCode":"\t\tcase \"map[string]intstr.IntOrString\":\n\t\t\tname, value, _ := strings.Cut(newValue, \"=\")\n\t\t\tv.SetMapIndex(reflect.ValueOf(name), reflect.ValueOf(intstr.Parse(value)))\n\n\t\tcase \"map[string][]string\":\n\t\t\tname, value, _ := strings.Cut(newValue, \"=\")\n\t\t\ttokens := strings.Split(value, \",\")\n\t\t\tvalueArray := reflect.MakeSlice(reflect.TypeOf(tokens), 0, v.Len()+len(tokens))\n\t\t\tfor _, s := range tokens {\n\t\t\t\tvalueItem := reflect.New(reflect.TypeOf(s))\n\t\t\t\tif err := setType(valueItem.Elem(), s); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tvalueArray = reflect.Append(valueArray, valueItem.Elem())\n\t\t\t}\n\t\t\tv.SetMapIndex(reflect.ValueOf(name), valueArray)\n\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unhandled type %q\", t)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tvar newV reflect.Value\n\n\tswitch t {\n\tcase \"string\":\n\t\tnewV = reflect.ValueOf(newValue)\n\n\tcase \"bool\":\n\t\tb, err := strconv.ParseBool(newValue)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot interpret %q value as bool\", newValue)\n\t\t}\n\t\tnewV = reflect.ValueOf(b)\n","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/reflectutils/access.go#L163-L199","documentation":"setType supports only map[string]string, map[string]intstr.IntOrString, and map[string][]string for map-typed fields; any other map value type falls into the default branch and errors with the concrete Go type name. Scalar/struct leaves outside the known switch also land here when the string cannot be converted.","triggerScenarios":"SetString on a field whose type is an unsupported map (e.g. map[string]int, map[string]CustomType) or an unsupported struct/slice leaf type that is not convertible from string.","commonSituations":"New kOps API fields with exotic map types used with `kops set`; custom addons config using map[string]interface{} (not supported at all).","solutions":["Set the field directly in Go code instead of via SetString.","Change the struct field to a supported map type (map[string]string).","Extend setType with a case for the new type if you own the code.","Use a JSON/YAML edit of the manifest instead of the reflective setter."],"exampleFix":"// before\nCounters map[string]int   // setType: unhandled type \"map[string]int\"\n// after\nCounters map[string]string // set with \"key=1\"","handlingStrategy":"type-guard","validationCode":"switch t.(type) {\ncase map[string]string, map[string][]string, map[string]intstr.IntOrString:\n    // supported\ndefault:\n    rv := reflect.ValueOf(t)\n    if rv.Kind() == reflect.Map {\n        return fmt.Errorf(\"unsupported map type %T for SetString\", t)\n    }\n}","typeGuard":"func isSupportedMap(v interface{}) bool {\n    switch v.(type) {\n    case map[string]string, map[string][]string, map[string]intstr.IntOrString:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err := SetString(&obj, path, val); err != nil {\n    var ue *unhandledTypeError // or string match on \"unhandled type\"\n    if strings.HasPrefix(err.Error(), \"unhandled type\") {\n        return fmt.Errorf(\"field %q has a type SetString cannot write; set it directly\", path)\n    }\n    return err\n}","preventionTips":["Restrict fields on mutation paths to supported map types.","Use map[string]string as the default map type in API structs.","Fall back to YAML/JSON editing for exotic types."],"tags":["go","reflection","unsupported-type"],"backgroundTag":"unhandled-reflect-type","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}