{"record":{"id":"c486dba34d09b089","repo":"vitessio/vitess","slug":"unexpected-format","errorCode":null,"errorMessage":"unexpected format: ","messagePattern":"unexpected format: ","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/sqlparser/tracked_buffer.go","lineNumber":242,"sourceCode":"\t\t\tcase uint16:\n\t\t\t\tbuf.WriteUint(uint64(v))\n\t\t\tcase uint32:\n\t\t\t\tbuf.WriteUint(uint64(v))\n\t\t\tcase uint64:\n\t\t\t\tbuf.WriteUint(v)\n\t\t\tcase uintptr:\n\t\t\t\tbuf.WriteUint(uint64(v))\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Sprintf(\"unexepcted TrackedBuffer type %T\", v))\n\t\t\t}\n\t\tcase 'a':\n\t\t\tbuf.WriteArg(\"\", values[fieldnum].(string))\n\t\tcase 'n':\n\t\t\t// used for printing slices of SQLNodes\n\t\t\tvalue := values[fieldnum]\n\t\t\tbuf.formatNodes(value)\n\t\tdefault:\n\t\t\tpanic(\"unexpected format: \" + string(format[i-1:i+1]))\n\t\t}\n\t\tfieldnum++\n\t\ti++\n\t}\n}\n\nfunc (buf *TrackedBuffer) formatExprs(exprs []Expr) {\n\tvar prefix string\n\tfor _, expr := range exprs {\n\t\tbuf.WriteString(prefix)\n\t\tbuf.formatter(expr)\n\t\tprefix = \", \"\n\t}\n}\n\nfunc (buf *TrackedBuffer) formatNodes(input any) {\n\tswitch nodes := input.(type) {\n\tcase []Expr:","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/sqlparser/tracked_buffer.go#L224-L260","documentation":"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.","triggerScenarios":"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).","commonSituations":"New AST code authored by copying standard-library fmt idioms (%q, %T) that TrackedBuffer does not implement.","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"],"exampleFix":"// before\nbuf.Myprintf(\"%q\", name)\n// after\nbuf.Myprintf(\"%s\", name)","handlingStrategy":"validation","validationCode":"supported := map[byte]bool{'c':true,'s':true,'d':true,'l':true,'r':true,'v':true,'a':true,'n':true,'w':true,'u':true}\nif len(verb) == 2 && !supported[verb[1]] {\n    return fmt.Errorf(\"unsupported TrackedBuffer verb %%%c\", verb[1])\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        t.Fatalf(\"AST formatting panicked (unknown format verb): %v\", r)\n    }\n}()","preventionTips":["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"],"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"}