{"record":{"id":"c78e46107385c6df","repo":"kubernetes/kops","slug":"buildflags-of-value-type-not-handled-t-s-v","errorCode":null,"errorMessage":"BuildFlags of value type not handled: %T %s=%v","messagePattern":"BuildFlags of value type not handled: %T (.+?)=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/flagbuilder/build_flags.go","lineNumber":119,"sourceCode":"\t\t\t\treturn nil\n\t\t\t}\n\t\t\t// We handle a map[string]string like --node-labels=k1=v1,k2=v2 etc\n\t\t\t// As we need more formats we can add additional spec to the flags tag\n\t\t\tif stringStringMap, ok := val.Interface().(map[string]string); ok {\n\t\t\t\tvar args []string\n\t\t\t\tfor k, v := range stringStringMap {\n\t\t\t\t\targ := fmt.Sprintf(\"%s=%s\", k, v)\n\t\t\t\t\targs = append(args, arg)\n\t\t\t\t}\n\t\t\t\tsort.Strings(args)\n\t\t\t\tif len(args) != 0 {\n\t\t\t\t\tflag := fmt.Sprintf(\"--%s=%s\", flagName, strings.Join(args, \",\"))\n\t\t\t\t\tflags = append(flags, flag)\n\t\t\t\t}\n\t\t\t\treturn reflectutils.SkipReflection\n\t\t\t}\n\n\t\t\treturn fmt.Errorf(\"BuildFlags of value type not handled: %T %s=%v\", val.Interface(), path, val.Interface())\n\t\t}\n\n\t\tif val.Kind() == reflect.Slice {\n\t\t\tif val.IsNil() {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\t// We handle a []string like --admission-control=v1,v2 etc\n\t\t\tif stringSlice, ok := val.Interface().([]string); ok {\n\t\t\t\tif len(stringSlice) != 0 {\n\t\t\t\t\tif repeatFlag {\n\t\t\t\t\t\tfor _, v := range stringSlice {\n\t\t\t\t\t\t\tflag := fmt.Sprintf(\"--%s=%s\", flagName, v)\n\t\t\t\t\t\t\tflags = append(flags, flag)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tflag := fmt.Sprintf(\"--%s=%s\", flagName, strings.Join(stringSlice, \",\"))\n\t\t\t\t\t\tflags = append(flags, flag)\n\t\t\t\t\t}","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/flagbuilder/build_flags.go#L101-L137","documentation":"The flag builder only knows how to render maps of type map[string]string. When reflection reaches a field with a `flag` tag whose underlying value is a Map of any other key/value type, it cannot serialize it and returns this error. It guards against silently emitting malformed flags.","triggerScenarios":"A field with a `flag` tag is a map[string]int, map[string]bool, map[string][]string, or any non-string-typed map (after pointer dereference), and BuildFlags/BuildFlagsList is called on the options struct.","commonSituations":"Introducing a new config field with a typed map and forgetting to convert it to map[string]string, or embedding third-party types (e.g. resource maps) into a flaggable struct.","solutions":["Change the field type to map[string]string, converting values to strings when populating it","Remove the `flag` tag from the field if it should not be rendered as a flag","Add a custom branch in the walker for the specific map type if string conversion is safe"],"exampleFix":"// before\nTaints map[string]int `flag:\"taints\"`\n// after\nTaints map[string]string `flag:\"taints\"`","handlingStrategy":"validation","validationCode":"// Ensure flag-tagged map fields are map[string]string before calling BuildFlagsList\nif m, ok := opts.SomeMap.(map[string]string); !ok {\n\treturn fmt.Errorf(\"SomeMap must be map[string]string, got %T\", opts.SomeMap)\n}","typeGuard":"func isStringStringMap(v reflect.Value) bool {\n\treturn v.Kind() != reflect.Map || v.Type() == reflect.TypeOf(map[string]string{})\n}","tryCatchPattern":"flags, err := flagbuilder.BuildFlagsList(opts)\nif err != nil {\n\tif strings.Contains(err.Error(), \"value type not handled\") {\n\t\tlog.Fatalf(\"config field has unsupported type for flag rendering: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Use map[string]string exclusively for flag-tagged maps","Convert typed values to strings when populating flaggable config structs","Add BuildFlagsList smoke tests covering all option structs in CI"],"tags":["reflection","flagbuilder","unsupported-type","maps"],"backgroundTag":"unsupported-flag-value-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"}