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

  1. Replace the unsupported verb with a supported one (%s, %d, %v, %c, %a, %n, %w, %u)
  2. Use buf.WriteString / fmt.Sprintf outside Myprintf for anything requiring stdlib-only verbs
  3. 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

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


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/c486dba34d09b089. Report an issue: GitHub.