vitessio/vitess · error
unexpected format:
Error message
unexpected format:
What it means
astPrintf encountered a format verb it does not recognize. TrackedBuffer supports a custom verb set (c,s,d,cases,l,r,v,a,n,w,u,etc.); any other letter after % reaches this default branch and panics, since there is no sensible fallback when printing ASTs.
Source
Thrown at go/vt/sqlparser/tracked_buffer.go:242
case uint16:
buf.WriteUint(uint64(v))
case uint32:
buf.WriteUint(uint64(v))
case uint64:
buf.WriteUint(v)
case uintptr:
buf.WriteUint(uint64(v))
default:
panic(fmt.Sprintf("unexepcted TrackedBuffer type %T", v))
}
case 'a':
buf.WriteArg("", values[fieldnum].(string))
case 'n':
// used for printing slices of SQLNodes
value := values[fieldnum]
buf.formatNodes(value)
default:
panic("unexpected format: " + string(format[i-1:i+1]))
}
fieldnum++
i++
}
}
func (buf *TrackedBuffer) formatExprs(exprs []Expr) {
var prefix string
for _, expr := range exprs {
buf.WriteString(prefix)
buf.formatter(expr)
prefix = ", "
}
}
func (buf *TrackedBuffer) formatNodes(input any) {
switch nodes := input.(type) {
case []Expr:View on GitHub (pinned to 01a25a7d17)
Solutions
- Replace the unsupported verb with a supported one (%s, %d, %v, %c, %a, %n, %w, %u)
- Use buf.WriteString / fmt.Sprintf outside Myprintf for anything requiring stdlib-only verbs
- Add a ToString() unit test for the node to verify formatting
Example fix
// before
buf.Myprintf("%q", name)
// after
buf.Myprintf("%s", name) Defensive patterns
Strategy: validation
Validate before calling
supported := map[byte]bool{'c':true,'s':true,'d':true,'l':true,'r':true,'v':true,'a':true,'n':true,'w':true,'u':true}
if len(verb) == 2 && !supported[verb[1]] {
return fmt.Errorf("unsupported TrackedBuffer verb %%%c", verb[1])
} Try / catch
defer func() {
if r := recover(); r != nil {
t.Fatalf("AST formatting panicked (unknown format verb): %v", r)
}
}() Prevention
- Only use verbs documented in TrackedBuffer's Myprintf; treat it as a custom printf, not stdlib fmt
- For stdlib-only formatting, use fmt.Sprintf and pass the result via %s
- Add AST printing tests when introducing new Format strings
When it happens
Trigger: Writing buf.Myprintf with an unsupported verb like %q or %f inside an AST Format/astPrintf path; typos in custom verbs (e.g. %x where %s was meant).
Common situations: New AST code authored by copying standard-library fmt idioms (%q, %T) that TrackedBuffer does not implement.
Related errors
- unexpected TrackedBuffer type %T
- unexepcted TrackedBuffer type %T
- 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/c486dba34d09b089.
Report an issue: GitHub.