grafana/k6 · error
invalid category filter
Error message
invalid category filter %q: %w
What it means
Returned by Logger.SetCategoryFilter when the provided filter string cannot be compiled as a regular expression (regexp.Compile fails); the '%q' is the offending filter and the wrapped error is a *regexp.CompileError with position details. The input at fault is the browser log category filter value, typically sourced from the K6_BROWSER_LOG_CATEGORY_FILTER environment variable or browser context options.
Solutions
- Fix the regex syntax in the category filter (escape special characters, balance parentheses)
- Test the pattern with a regex tool before passing it to k6
- Leave the filter empty to disable filtering
- Check the wrapped error message for the exact syntax error position
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/log/logger.go:160 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/b73d0e602d91df41.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/log/logger.go:160
return f.Func.Name(), fmt.Sprintf("%s:%d", f.File, f.Line)
}
}
l.SetFormatter(&logrus.TextFormatter{
CallerPrettyfier: caller(),
FieldMap: logrus.FieldMap{
logrus.FieldKeyFile: "caller",
},
})
l.SetReportCaller(true)
}
// SetCategoryFilter enables filtering logs by the filter regex.
func (l *Logger) SetCategoryFilter(filter string) (err error) {
if filter == "" {
return nil
}
if l.categoryFilter, err = regexp.Compile(filter); err != nil {
return fmt.Errorf("invalid category filter %q: %w", filter, err)
}
return nil
}
View on GitHub (pinned to 01ffac6f24)