{"record":{"id":"eacc65420702ade0","repo":"vitessio/vitess","slug":"element-does-not-implement-sqlnode","errorCode":null,"errorMessage":"element does not implement SQLNode","messagePattern":"element does not implement SQLNode","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/sqlparser/tracked_buffer.go","lineNumber":282,"sourceCode":"\n\t// SLOW PATH! Add specific cases above to avoid reflection.\n\n\t// Check if the input is a slice\n\tval := reflect.ValueOf(input)\n\tif val.Kind() != reflect.Slice {\n\t\t// Handle the error or return if input is not a slice\n\t\tpanic(\"input is not a slice\")\n\t}\n\n\t// Iterate over the slice elements\n\tfor i := 0; i < val.Len(); i++ {\n\t\telem := val.Index(i).Interface()\n\n\t\t// Assert each element implements SQLNode\n\t\tnode, ok := elem.(SQLNode)\n\t\tif !ok {\n\t\t\t// Handle the error or skip non-SQLNode elements\n\t\t\tpanic(\"element does not implement SQLNode\")\n\t\t}\n\n\t\t// Now `node` is of type SQLNode\n\t\t// You can call methods or use it as a SQLNode here\n\t\tbuf.Myprintf(\"%v\", node)\n\t}\n}\n\nfunc getExpressionForParensEval(checkParens bool, value any) Expr {\n\tif checkParens {\n\t\texpr, isExpr := value.(Expr)\n\t\tif isExpr {\n\t\t\treturn expr\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/sqlparser/tracked_buffer.go#L264-L300","documentation":"Error in sqlparser's tracked_buffer: an element of a node list does not implement the SQLNode interface, so it cannot be printed/walked during AST generation. Thrown at go/vt/sqlparser/tracked_buffer.go:282.","triggerScenarios":"Passing to %n a slice of non-SQLNode elements, e.g. []string, []Token, or []*topodatapb.X instead of []SQLNode / node slice types.","commonSituations":"Hand-written Format methods passing auxiliary string slices or internal enum slices with %n.","solutions":["Convert elements to their SQLNode wrappers before formatting","Use a string verb (%s) joined with separators for plain strings instead of %n","Ensure the slice type used in Format embeds SQLNode-implementing element types"],"exampleFix":"// before\nbuf.Myprintf(\"%n\", names) // []string\n// after\nbuf.Myprintf(\"%n\", cols) // []SelectExpr (SQLNode)","handlingStrategy":"type-guard","validationCode":"for _, e := range elems {\n    if _, ok := e.(SQLNode); !ok {\n        return fmt.Errorf(\"%%n slice contains non-SQLNode %T\", e)\n    }\n}","typeGuard":"func asSQLNodeSlice(v any) ([]SQLNode, bool) {\n    rv := reflect.ValueOf(v)\n    if rv.Kind() != reflect.Slice {\n        return nil, false\n    }\n    out := make([]SQLNode, 0, rv.Len())\n    for i := 0; i < rv.Len(); i++ {\n        n, ok := rv.Index(i).Interface().(SQLNode)\n        if !ok {\n            return nil, false\n        }\n        out = append(out, n)\n    }\n    return out, true\n}","tryCatchPattern":null,"preventionTips":["Ensure slice types passed to %n contain SQLNode-implementing elements","Use string verbs with strings.Join for plain []string fields","Add compile-time assertions like var _ SQLNode = (*MyNode)(nil)"],"tags":["sqlparser","tracked-buffer","type-assertion","panic","ast"],"backgroundTag":"format-string-mismatch","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}