{"record":{"id":"c8e2645b7c8de003","repo":"vitessio/vitess","slug":"cannot-compile-regexp-v-for-table-v","errorCode":null,"errorMessage":"cannot compile regexp %v for table: %v","messagePattern":"cannot compile regexp (.+?) for table: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/tmutils/schema.go","lineNumber":75,"sourceCode":"// (tables), no denied tables (excludeTables) and optionally\n// views (includeViews).\nfunc NewTableFilter(tables, excludeTables []string, includeViews bool) (*TableFilter, error) {\n\tf := &TableFilter{\n\t\tincludeViews: includeViews,\n\t}\n\n\t// Build a list of regexp to match table names against.\n\t// We only use regexps if the name starts and ends with '/'.\n\t// Otherwise the entry in the arrays is nil, and we use the original\n\t// table name.\n\tif len(tables) > 0 {\n\t\tf.filterTables = true\n\t\tfor _, table := range tables {\n\t\t\tif strings.HasPrefix(table, \"/\") {\n\t\t\t\ttable = strings.Trim(table, \"/\")\n\t\t\t\tre, err := regexp.Compile(table)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"cannot compile regexp %v for table: %v\", table, err)\n\t\t\t\t}\n\n\t\t\t\tf.tableREs = append(f.tableREs, re)\n\t\t\t} else {\n\t\t\t\tf.tableNames = append(f.tableNames, table)\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(excludeTables) > 0 {\n\t\tf.filterExcludeTables = true\n\t\tfor _, table := range excludeTables {\n\t\t\tif strings.HasPrefix(table, \"/\") {\n\t\t\t\ttable = strings.Trim(table, \"/\")\n\t\t\t\tre, err := regexp.Compile(table)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"cannot compile regexp %v for excludeTable: %v\", table, err)\n\t\t\t\t}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/tmutils/schema.go#L57-L93","documentation":"NewTableFilter builds table filters for schema reloads (GetSchema). Entries starting with '/' are treated as regular expressions matched against table names; if one of those regexps fails to compile, NewTableFilter returns this error and the schema request fails.","triggerScenarios":"Passing a malformed regex in the tables list, e.g. tmutils.NewTableFilter([]string{\"/user[/\"}, ...) or any vtctldclient/vttablet GetSchema call with an invalid /regex/ table filter.","commonSituations":"Typo in a regex table filter (unbalanced brackets, dangling quantifier like 'orders+' miswritten as 'orders+['); shell escaping stripped or altered characters in the pattern; copying a glob pattern (e.g. 'tmp_*') into a regex position incorrectly.","solutions":["Fix the regexp syntax in the tables argument (validate it with regexp.MustCompile in a scratch test or a Go playground)","Escape special regex characters in table names that contain ., (, ), [, etc.","If the entry is meant to be a literal name, remove the leading '/' so it is treated as an exact table name"],"exampleFix":"// before\nf, err := tmutils.NewTableFilter([]string{\"/user[/\"}, nil, false)\n// after\nf, err := tmutils.NewTableFilter([]string{\"/^user_/\"}, nil, false)","handlingStrategy":"validation","validationCode":"func validateTableFilters(tables []string) error {\n    for _, t := range tables {\n        if strings.HasPrefix(t, \"/\") {\n            if _, err := regexp.Compile(strings.Trim(t, \"/\")); err != nil {\n                return fmt.Errorf(\"invalid table regexp %q: %v\", t, err)\n            }\n        }\n    }\n    return nil\n}","typeGuard":"func isRegexTableFilter(entry string) bool {\n    return strings.HasPrefix(entry, \"/\")\n}","tryCatchPattern":"f, err := tmutils.NewTableFilter(tables, excludeTables, includeViews)\nif err != nil {\n    return vterrors.Wrapf(err, \"invalid table filter configuration\")\n}","preventionTips":["Unit-test every regex table filter before deploying it in config","Escape regex metacharacters when filtering literal table names","Keep patterns simple (anchored prefixes like /^tmp_/) to reduce syntax risk","Validate filter flags in CLI PreRunE before invoking the schema API"],"tags":["regex","schema","configuration","vitess"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}