{"record":{"id":"3fe4167afa6b2650","repo":"vitessio/vitess","slug":"unsupported-pointer-type-t","errorCode":null,"errorMessage":"unsupported pointer type %T","messagePattern":"unsupported pointer type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/tools/asthelpergen/asthelpergen.go","lineNumber":412,"sourceCode":"\t\t\treturn fmt.Errorf(\"don't know how to handle type %s %T\", typeName, underlying)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"generator failed for type %s: %w\", typeName, err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// handlePointerType handles pointer types by dispatching to the appropriate method\nfunc (gen *astHelperGen) handlePointerType(t types.Type, ptr *types.Pointer, g generator) error {\n\tptrToType := ptr.Elem().Underlying()\n\tswitch ptrToType := ptrToType.(type) {\n\tcase *types.Struct:\n\t\treturn g.ptrToStructMethod(t, ptrToType, gen)\n\tcase *types.Basic:\n\t\treturn g.ptrToBasicMethod(t, ptrToType, gen)\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported pointer type %T\", ptrToType)\n\t}\n}\n\n// generateOutputFiles collects the generated files from all generators\nfunc (gen *astHelperGen) generateOutputFiles() map[string]*jen.File {\n\tresult := map[string]*jen.File{}\n\tfor _, g := range gen.gens {\n\t\tfName, jenFile := g.genFile(gen)\n\t\tresult[fName] = jenFile\n\t}\n\treturn result\n}\n\n// noQualifier is used to print types without package qualifiers\nvar 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 {","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/tools/asthelpergen/asthelpergen.go#L394-L430","documentation":"In asthelpergen, handlePointerType receives a pointer type and switches on what the pointer points to. Only *types.Struct and *types.Basic targets are supported; any other pointee kind (slice, map, interface, named pointer types, etc.) returns this error and aborts generation for that type.","triggerScenarios":"Adding an AST field/type that is a pointer to something other than a struct or basic type — e.g. `*[]Statement`, `*map[string]Expr`, or a pointer to an interface — then running asthelpergen.","commonSituations":"A new sqlparser AST node introduces a pointer field with an unusual pointee kind; codegen is run after refactoring an AST type from struct to interface (or vice versa); generator tests added a synthetic type for coverage.","solutions":["Identify the offending type %T printed in the error and find which AST type declares it","Add a case to handlePointerType for the new pointee kind with a dedicated generator method","Alternatively, redesign the AST field so it points to a struct or basic type (matching existing AST conventions)","Re-run asthelpergen / `make codegen` to verify all queued types now pass"],"exampleFix":"// before\ndefault:\n    return fmt.Errorf(\"unsupported pointer type %T\", ptrToType)\n// after\ncase *types.Slice:\n    return g.ptrToSliceMethod(t, ptrToType, gen)\ndefault:\n    return fmt.Errorf(\"unsupported pointer type %T\", ptrToType)","handlingStrategy":"validation","validationCode":"// Validate pointee kinds before generation\nfor _, f := range astFields {\n    ptr, ok := f.Type().(*types.Pointer)\n    if !ok { continue }\n    switch ptr.Elem().Underlying().(type) {\n    case *types.Struct, *types.Basic:\n    default:\n        return fmt.Errorf(\"field %s is a pointer to %T; unsupported by asthelpergen\", f.Name(), ptr.Elem().Underlying())\n    }\n}","typeGuard":"func isSupportedPointee(t types.Type) bool {\n    p, ok := t.(*types.Pointer)\n    if !ok { return false }\n    switch p.Elem().Underlying().(type) {\n    case *types.Struct, *types.Basic:\n        return true\n    default:\n        return false\n    }\n}","tryCatchPattern":"if err := g.handlePointerType(t, elem, gen); err != nil {\n    if strings.Contains(err.Error(), \"unsupported pointer type\") {\n        return fmt.Errorf(\"add a generator for pointee kind: %w\", err)\n    }\n    return err\n}","preventionTips":["Follow existing AST conventions: pointer fields should reference structs or basic types","Add a lint/pre-check that scans AST fields for unsupported pointee kinds before codegen","When introducing new pointee kinds, extend handlePointerType and its tests in the same PR"],"tags":["codegen","ast","go","tooling"],"backgroundTag":"codegen-generator-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}