{"record":{"id":"8ed13298edc64f04","repo":"vitessio/vitess","slug":"panic-err-error-from-convertmysqlversiontocomme","errorCode":null,"errorMessage":"panic(err) — error from ConvertMySQLVersionToCommentVersion(config.DefaultMySQLVersion)","messagePattern":"panic\\(err\\) — error from ConvertMySQLVersionToCommentVersion\\(config\\.DefaultMySQLVersion\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"go/vt/sqlparser/parser.go","lineNumber":399,"sourceCode":"func New(opts Options) (*Parser, error) {\n\tif opts.MySQLServerVersion == \"\" {\n\t\topts.MySQLServerVersion = config.DefaultMySQLVersion\n\t}\n\tconvVersion, err := ConvertMySQLVersionToCommentVersion(opts.MySQLServerVersion)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Parser{\n\t\tversion:        convVersion,\n\t\ttruncateUILen:  opts.TruncateUILen,\n\t\ttruncateErrLen: opts.TruncateErrLen,\n\t}, nil\n}\n\nfunc NewTestParser() *Parser {\n\tconvVersion, err := ConvertMySQLVersionToCommentVersion(config.DefaultMySQLVersion)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &Parser{\n\t\tversion:        convVersion,\n\t\ttruncateUILen:  512,\n\t\ttruncateErrLen: 0,\n\t}\n}\n","sourceCodeStart":381,"sourceCodeEnd":407,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/sqlparser/parser.go#L381-L407","documentation":"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.","triggerScenarios":"Calling NewTestParser() when config.DefaultMySQLVersion is not a string recognized by ConvertMySQLVersionToCommentVersion (malformed like \"x.y\", or too new/old to map).","commonSituations":"A config package change bumping DefaultMySQLVersion to an unsupported value while sqlparser's converter lags; tests using NewTestParser after a dependency merge.","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"],"exampleFix":"// before\nconfig.DefaultMySQLVersion = \"99.99\"\n// after\nconfig.DefaultMySQLVersion = \"8.0.35\"","handlingStrategy":"try-catch","validationCode":"if _, err := sqlparser.ConvertMySQLVersionToCommentVersion(config.DefaultMySQLVersion); err != nil {\n    // fix config.DefaultMySQLVersion before calling NewTestParser\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        t.Fatalf(\"NewTestParser panicked (check config.DefaultMySQLVersion): %v\", r)\n    }\n}()\np := sqlparser.NewTestParser()","preventionTips":["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"],"tags":["sqlparser","test-setup","version-conversion","panic","config"],"backgroundTag":"unsupported-version","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}