vitessio/vitess · critical
panic(err) — error from ConvertMySQLVersionToCommentVersion(
Error message
panic(err) — error from ConvertMySQLVersionToCommentVersion(config.DefaultMySQLVersion)
What it means
NewTestParser creates a Parser with Vitess's DefaultMySQLVersion converted to a parser comment version. If ConvertMySQLVersionToCommentVersion cannot map that default constant (e.g. the default version constant was bumped to an unrecognized string), it panics — a build/config-time invariant failure rather than a runtime user error.
Source
Thrown at go/vt/sqlparser/parser.go:399
func New(opts Options) (*Parser, error) {
if opts.MySQLServerVersion == "" {
opts.MySQLServerVersion = config.DefaultMySQLVersion
}
convVersion, err := ConvertMySQLVersionToCommentVersion(opts.MySQLServerVersion)
if err != nil {
return nil, err
}
return &Parser{
version: convVersion,
truncateUILen: opts.TruncateUILen,
truncateErrLen: opts.TruncateErrLen,
}, nil
}
func NewTestParser() *Parser {
convVersion, err := ConvertMySQLVersionToCommentVersion(config.DefaultMySQLVersion)
if err != nil {
panic(err)
}
return &Parser{
version: convVersion,
truncateUILen: 512,
truncateErrLen: 0,
}
}
View on GitHub (pinned to 01a25a7d17)
Solutions
- Check config.DefaultMySQLVersion and make sure it is a valid dotted MySQL version string
- Update ConvertMySQLVersionToCommentVersion to support the new default version
- As a workaround in tests, construct &Parser{version: ...} directly with a known-good version
Example fix
// before config.DefaultMySQLVersion = "99.99" // after config.DefaultMySQLVersion = "8.0.35"
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := sqlparser.ConvertMySQLVersionToCommentVersion(config.DefaultMySQLVersion); err != nil {
// fix config.DefaultMySQLVersion before calling NewTestParser
} Try / catch
defer func() {
if r := recover(); r != nil {
t.Fatalf("NewTestParser panicked (check config.DefaultMySQLVersion): %v", r)
}
}()
p := sqlparser.NewTestParser() Prevention
- Keep config.DefaultMySQLVersion in lockstep with versions ConvertMySQLVersionToCommentVersion supports
- Add a test that converts the default version at init/test time
- Pin the version used in tests to a known-supported value
When it happens
Trigger: Calling NewTestParser() when config.DefaultMySQLVersion is not a string recognized by ConvertMySQLVersionToCommentVersion (malformed like "x.y", or too new/old to map).
Common situations: A config package change bumping DefaultMySQLVersion to an unsupported value while sqlparser's converter lags; tests using NewTestParser after a dependency merge.
Related errors
- no zk server found for host %v in config %v
- GetFuncForType does not support array types
- GetFuncForType does not support channel types
- GetFuncForType does not support function types
- GetFuncForType does not support interface types (specify a s
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/8ed13298edc64f04.
Report an issue: GitHub.