vitessio/vitess · error
cannot compile regexp %v for excludeTable: %v
Error message
cannot compile regexp %v for excludeTable: %v
What it means
NewTableFilter treats entries in excludeTables that start with '/' as regular expressions; if such an entry fails regexp.Compile, this error is returned and the TableFilter is not created. Functionally identical to the tables variant, but for the exclusion list.
Source
Thrown at go/vt/mysqlctl/tmutils/schema.go:92
if err != nil {
return nil, fmt.Errorf("cannot compile regexp %v for table: %v", table, err)
}
f.tableREs = append(f.tableREs, re)
} else {
f.tableNames = append(f.tableNames, table)
}
}
}
if len(excludeTables) > 0 {
f.filterExcludeTables = true
for _, table := range excludeTables {
if strings.HasPrefix(table, "/") {
table = strings.Trim(table, "/")
re, err := regexp.Compile(table)
if err != nil {
return nil, fmt.Errorf("cannot compile regexp %v for excludeTable: %v", table, err)
}
f.excludeTableREs = append(f.excludeTableREs, re)
} else {
f.excludeTableNames = append(f.excludeTableNames, table)
}
}
}
return f, nil
}
// Includes returns whether a tableName/tableType should be included in this TableFilter.
func (f *TableFilter) Includes(tableName string, tableType string) bool {
if f.filterTables {
matches := false
for _, name := range f.tableNames {
if strings.EqualFold(name, tableName) {View on GitHub (pinned to 01a25a7d17)
Solutions
- Correct the regexp in excludeTables; test it with a quick regexp.Compile check first
- Escape regex metacharacters in literal table names
- Drop the leading/trailing slashes if you intended an exact-name exclusion
Example fix
// before
tmutils.NewTableFilter(nil, []string{"/_test[/"}, false)
// after
tmutils.NewTableFilter(nil, []string{"/_test_.*"}, false) Defensive patterns
Strategy: validation
Validate before calling
for _, t := range excludeTables {
if strings.HasPrefix(t, "/") {
if _, err := regexp.Compile(strings.Trim(t, "/")); err != nil {
return fmt.Errorf("invalid excludeTable regexp %q: %v", t, err)
}
}
} Type guard
func isRegexExcludeFilter(entry string) bool {
return strings.HasPrefix(entry, "/")
} Try / catch
f, err := tmutils.NewTableFilter(nil, excludeTables, false)
if err != nil {
return vterrors.Wrapf(err, "invalid excludeTables configuration")
} Prevention
- Test exclusion regexps against the expected table list before use
- Quote patterns properly in shell to avoid metacharacter mangling
- Prefer exact names for simple exclusions and reserve /regex/ for real patterns
- Add endtoend/config validation for exclude-table flags
When it happens
Trigger: Calling NewTableFilter (or higher-level GetSchema flows that pass excludeTables, e.g. vtctl schema commands) with an invalid /regex/ entry in the excludeTables slice.
Common situations: Malformed exclusion pattern like '/_(tmp$/'; unescaped metacharacters from copy-paste; shell quoting issues mangling the pattern before it reaches the API.
Related errors
- cannot compile regexp %v for table: %v
- schemas are different: %s: %v, %s: %v
- schemas are different: %s: %v differs from: %s: %v
- %v has an extra table named %v
- schemas differ on table %v: %s: %v differs from: %s: %v
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/2909b3d16d46189f.
Report an issue: GitHub.