{"record":{"id":"d872b06a94041712","repo":"kubernetes/kops","slug":"unhandled-type-at-path-q-t","errorCode":null,"errorMessage":"unhandled type at path %q: %T","messagePattern":"unhandled type at path %q: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/jsonutils/transform.go","lineNumber":76,"sourceCode":"// visitAny is a helper function that visits any value in the JSON tree\nfunc (o *Transformer) visitAny(v any, path string) (any, error) {\n\tif v == nil {\n\t\treturn v, nil\n\t}\n\tswitch v := v.(type) {\n\tcase map[string]any:\n\t\tif err := o.visitMap(v, path); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn v, nil\n\tcase []any:\n\t\treturn o.visitSlice(v, path)\n\tcase int64, float64, bool:\n\t\treturn o.visitPrimitive(v, path)\n\tcase string:\n\t\treturn o.visitString(v, path)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unhandled type at path %q: %T\", path, v)\n\t}\n}\n\nfunc (o *Transformer) visitMap(m map[string]any, path string) error {\n\tfor _, fn := range o.objectTransforms {\n\t\tif err := fn(path, m); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfor k, v := range m {\n\t\tchildPath := path + \".\" + k\n\n\t\tv2, err := o.visitAny(v, childPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tm[k] = v2","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/jsonutils/transform.go#L58-L94","documentation":"Transformer.visitAny only knows how to walk map[string]any, []any, string, int64, float64, bool, and nil. A value of any other Go type inside the tree (int, json.Number, custom structs, time.Time, etc.) cannot be transformed and produces this error naming the offending type and its JSON path. Trees are normally produced by decoding into map[string]any with encoding/json, which cannot produce such types, so this indicates values were inserted programmatically or decoded differently (e.g. yaml.v3 yields map[string]any but can yield int for small numbers).","triggerScenarios":"Calling Transformer.Transform on a tree built from yaml.v3 Unmarshal (small integers become int, not int64), on a tree containing json.Number values, or after inserting typed values (structs, time.Time) into the map.","commonSituations":"Transforming YAML-derived config (kOps manifests loaded via YAML) where integer values decode as int; mixing json.Decoder(UseNumber) output with the Transformer.","solutions":["Normalize the tree before Transform: convert all numbers to int64/float64 (e.g. re-marshal with encoding/json into map[string]any).","If the tree came from YAML, convert int values to int64 in a pre-pass.","Extend the switch in visitAny to handle the extra type if you control the library."],"exampleFix":"// before\nvar m map[string]any\nyaml.Unmarshal(data, &m)\nt.Transform(m) // int values fail\n// after\nj, _ := json.Marshal(m)\nvar m2 map[string]any\njson.Unmarshal(j, &m2) // numbers become float64\nt.Transform(m2)","handlingStrategy":"validation","validationCode":"func normalizeJSONTypes(v any) (any, error) {\n\tj, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar out any\n\tif err := json.Unmarshal(j, &out); err != nil {\n\t\treturn nil, err\n\t}\n\treturn out, nil\n}\n// round-trip the tree through JSON before Transformer.Transform","typeGuard":"func isTransformable(v any) bool {\n\tswitch v.(type) {\n\tcase nil, map[string]any, []any, string, int64, float64, bool:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"if err := transformer.Transform(tree); err != nil {\n\treturn fmt.Errorf(\"transform failed: %w\", err)\n}","preventionTips":["Round-trip YAML-derived data through encoding/json before Transform.","Avoid inserting typed Go values (structs, time.Time, json.Number) into the tree.","Recursively check trees with isTransformable in tests."],"tags":["json","transform","type-mismatch"],"backgroundTag":"unsupported-type-in-json-tree","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"}