{"record":{"id":"cf2659ba17a786cf","repo":"vitessio/vitess","slug":"unknown-type-t-v","errorCode":null,"errorMessage":"unknown type %T %v","messagePattern":"unknown type %T (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/tools/asthelpergen/asthelpergen.go","lineNumber":445,"sourceCode":"var noQualifier = func(*types.Package) string { return \"\" }\n\n// printableTypeName returns a string that can be used as a valid golang identifier\nfunc printableTypeName(t types.Type) string {\n\tswitch t := t.(type) {\n\tcase *types.Alias:\n\t\treturn printableTypeName(types.Unalias(t))\n\tcase *types.Pointer:\n\t\treturn \"RefOf\" + printableTypeName(t.Elem())\n\tcase *types.Slice:\n\t\treturn \"SliceOf\" + printableTypeName(t.Elem())\n\tcase *types.Named:\n\t\treturn t.Obj().Name()\n\tcase *types.Basic:\n\t\treturn textutil.Title(t.Name())\n\tcase *types.Interface:\n\t\treturn t.String()\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown type %T %v\", t, t))\n\t}\n}\n","sourceCodeStart":427,"sourceCodeEnd":448,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/tools/asthelpergen/asthelpergen.go#L427-L448","documentation":"asthelpergen's printableTypeName converts go/types values into the human-readable type names used in generated helper method names and comments. It handles Named, Pointer, Slice, Basic, and Interface types; anything else (map, struct literal, chan, tuple, etc.) hits the default case and panics. It is a dev-time codegen failure.","triggerScenarios":"Running asthelpergen over a type graph that includes a types.Type kind outside the known set — e.g. a *types.Map, *types.Struct, *types.Chan or *types.Signature reachable from a queued type during processTypeQueue/processTypeWithGenerators, or via readValueOfType/structMethod/sliceMethod recursion.","commonSituations":"A developer adds a new AST helper for a type containing a map or struct field, or a generics instantiation that surfaces an unsupported type kind, then runs make codegen.","solutions":["Add a case for the offending *types.Type kind in printableTypeName (go/tools/asthelpergen/asthelpergen.go) returning a sensible printable name","Simplify the input type so it only contains supported kinds (named, pointer, slice, basic, interface)","Check the type queue printed in the panic message (%T %v) to see exactly which kind leaked in and where from"],"exampleFix":"// before (helpergen input)\ntype Foo struct { M map[string]string }\n// after\ntype Bar struct { M string } // or add a *types.Map case to printableTypeName","handlingStrategy":"type-guard","validationCode":"// Check the type kind before queuing it in asthelpergen\nswitch t.Underlying().(type) {\ncase *types.Named, *types.Pointer, *types.Slice, *types.Basic, *types.Interface:\n    // ok\ndefault:\n    return fmt.Errorf(\"asthelpergen: unsupported type %s\", t)\n}","typeGuard":"func supportedForHelperGen(t types.Type) bool {\n    switch t.(type) {\n    case *types.Named, *types.Pointer, *types.Slice, *types.Basic, *types.Interface:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Avoid maps/chans/structs in types you feed to asthelpergen, or extend printableTypeName when you add a kind","Run make codegen after every new helper type definition","Read the %T in the panic to identify the exact unsupported kind quickly"],"tags":["codegen","go","build-time","asthelpergen","go-types"],"backgroundTag":"unknown-type-kind","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}