vitessio/vitess · error
unexpected TrackedBuffer type %T
Error message
unexpected TrackedBuffer type %T
What it means
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.
Source
Thrown at go/vt/sqlparser/tracked_buffer.go:189
i++ // '%'
caseSensitive := false
if format[i] == '#' {
caseSensitive = true
i++
}
switch format[i] {
case 's':
switch v := values[fieldnum].(type) {
case string:
if caseSensitive {
buf.WriteString(v)
} else {
_, _ = buf.literal(v)
}
default:
panic(fmt.Sprintf("unexpected TrackedBuffer type %T", v))
}
case 'l', 'r', 'v':
left := format[i] != 'r'
value := values[fieldnum]
expr := getExpressionForParensEval(checkParens, value)
if expr == nil {
buf.formatter(value.(SQLNode))
} else {
needParens := needParens(currentExpr, expr, left)
if needParens {
buf.WriteByte('(')
}
buf.formatter(expr)
if needParens {
buf.WriteByte(')')
}
}View on GitHub (pinned to 01a25a7d17)
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
Example fix
// before
buf.Myprintf("%s", node.Name)
// after
buf.Myprintf("%s", node.Name.String()) Defensive patterns
Strategy: validation
Validate before calling
switch v := value.(type) {
case string:
buf.Myprintf("%s", v)
default:
return fmt.Errorf("%%s requires string, got %T", v)
} Try / catch
defer func() {
if r := recover(); r != nil {
t.Fatalf("AST formatting panicked (check Format %%s argument types): %v\n%s", r, debug.Stack())
}
}() Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unexepcted TrackedBuffer type %T
- unexpected format:
- input is not a slice
- element does not implement SQLNode
- invalid IntervalDateExpr syntax
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/fe1c1ecc1865697e.
Report an issue: GitHub.