{"record":{"id":"fe1c1ecc1865697e","repo":"vitessio/vitess","slug":"unexpected-trackedbuffer-type-t","errorCode":null,"errorMessage":"unexpected TrackedBuffer type %T","messagePattern":"unexpected TrackedBuffer type %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/sqlparser/tracked_buffer.go","lineNumber":189,"sourceCode":"\t\ti++ // '%'\n\n\t\tcaseSensitive := false\n\t\tif format[i] == '#' {\n\t\t\tcaseSensitive = true\n\t\t\ti++\n\t\t}\n\n\t\tswitch format[i] {\n\t\tcase 's':\n\t\t\tswitch v := values[fieldnum].(type) {\n\t\t\tcase string:\n\t\t\t\tif caseSensitive {\n\t\t\t\t\tbuf.WriteString(v)\n\t\t\t\t} else {\n\t\t\t\t\t_, _ = buf.literal(v)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Sprintf(\"unexpected TrackedBuffer type %T\", v))\n\t\t\t}\n\t\tcase 'l', 'r', 'v':\n\t\t\tleft := format[i] != 'r'\n\t\t\tvalue := values[fieldnum]\n\t\t\texpr := getExpressionForParensEval(checkParens, value)\n\n\t\t\tif expr == nil {\n\t\t\t\tbuf.formatter(value.(SQLNode))\n\t\t\t} else {\n\t\t\t\tneedParens := needParens(currentExpr, expr, left)\n\t\t\t\tif needParens {\n\t\t\t\t\tbuf.WriteByte('(')\n\t\t\t\t}\n\t\t\t\tbuf.formatter(expr)\n\t\t\t\tif needParens {\n\t\t\t\t\tbuf.WriteByte(')')\n\t\t\t\t}\n\t\t\t}","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/sqlparser/tracked_buffer.go#L171-L207","documentation":"TrackedBuffer's astPrintf implements a custom printf engine. The %s (case-insensitive string) verb received a value whose Go type is not string/[]byte, so it cannot render it, and panics to surface the AST-format-string mismatch immediately during development.","triggerScenarios":"An AST node's Format() calls buf.Myprintf(\"%s\", v) where v is not a string (e.g. passing a Token ID, struct, or []IdentifierCI); format/value count mismatches in a hand-written Format method.","commonSituations":"Writing or editing a new AST node's Format method and passing the wrong field for the %s verb; changing a field's type from string to a struct without updating Format.","solutions":["Fix the Format method to pass a string-typed value to %s (use v.ToString() or the String() of the field)","Use %v for SQLNode values instead of %s","Add/adjust unit tests that call ToString() on the affected node to catch regressions"],"exampleFix":"// before\nbuf.Myprintf(\"%s\", node.Name)\n// after\nbuf.Myprintf(\"%s\", node.Name.String())","handlingStrategy":"validation","validationCode":"switch v := value.(type) {\ncase string:\n    buf.Myprintf(\"%s\", v)\ndefault:\n    return fmt.Errorf(\"%%s requires string, got %T\", v)\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        t.Fatalf(\"AST formatting panicked (check Format %%s argument types): %v\\n%s\", r, debug.Stack())\n    }\n}()","preventionTips":["Match every %s verb to a string-typed field; call .String()/ToString() for structured types","Use %v for SQLNode arguments","Add ToString() round-trip tests for every new AST node type"],"tags":["sqlparser","tracked-buffer","format-string","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"}