grafana/k6 · error
parsing URL pattern
Error message
parsing URL pattern: %w
What it means
Returned by Frame.WaitForNavigation when building the URL matcher from the options fails: the provided glob/regex pattern string cannot be compiled. User-input validation of the URL pattern before any navigation waiting starts.
Solutions
- Fix the URL pattern (valid glob or regex syntax)
- Escape regex special characters when a literal match is intended
- Simplify the pattern to isolate the syntax error
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/frame.go:2085 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/1ef63af19aebaa81.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame.go:2093
}
// WaitForNavigation waits for the given navigation lifecycle event to happen.
// RegExMatcher should be non-nil to be able to test against a URL pattern in the options.
//
//nolint:funlen
func (f *Frame) WaitForNavigation(opts *FrameWaitForNavigationOptions, rm RegExMatcher) (*Response, error) {
f.log.Debugf("Frame:WaitForNavigation",
"fid:%s furl:%s url:%s", f.ID(), f.URL(), opts.URL)
defer f.log.Debugf("Frame:WaitForNavigation:return",
"fid:%s furl:%s", f.ID(), f.URL())
timeoutCtx, timeoutCancel := context.WithTimeout(f.ctx, opts.Timeout)
// Create URL matcher based on the pattern
matcher, err := newPatternMatcher(opts.URL, rm)
if err != nil {
timeoutCancel()
return nil, fmt.Errorf("parsing URL pattern: %w", err)
}
var matcherErr error
navEvtCh, navEvtCancel := createWaitForEventPredicateHandler(timeoutCtx, f, []string{EventFrameNavigation},
func(data any) bool {
if navEvt, ok := data.(*NavigationEvent); ok {
// Check if the navigation URL matches the pattern
matched, err := matcher(navEvt.url)
if err != nil {
matcherErr = err
// Return true here even though it's not correct and no match
// was found. We need this to exit asap so that the error can be
// propagated to the caller.
return true
}
return matched
}
return falseView on GitHub (pinned to 3fcf5388d7)