{"record":{"id":"1ef63af19aebaa81","repo":"grafana/k6","slug":"parsing-url-pattern-w","errorCode":null,"errorMessage":"parsing URL pattern: %w","messagePattern":"parsing URL pattern: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":2093,"sourceCode":"}\n\n// WaitForNavigation waits for the given navigation lifecycle event to happen.\n// RegExMatcher should be non-nil to be able to test against a URL pattern in the options.\n//\n//nolint:funlen\nfunc (f *Frame) WaitForNavigation(opts *FrameWaitForNavigationOptions, rm RegExMatcher) (*Response, error) {\n\tf.log.Debugf(\"Frame:WaitForNavigation\",\n\t\t\"fid:%s furl:%s url:%s\", f.ID(), f.URL(), opts.URL)\n\tdefer f.log.Debugf(\"Frame:WaitForNavigation:return\",\n\t\t\"fid:%s furl:%s\", f.ID(), f.URL())\n\n\ttimeoutCtx, timeoutCancel := context.WithTimeout(f.ctx, opts.Timeout)\n\n\t// Create URL matcher based on the pattern\n\tmatcher, err := newPatternMatcher(opts.URL, rm)\n\tif err != nil {\n\t\ttimeoutCancel()\n\t\treturn nil, fmt.Errorf(\"parsing URL pattern: %w\", err)\n\t}\n\n\tvar matcherErr error\n\tnavEvtCh, navEvtCancel := createWaitForEventPredicateHandler(timeoutCtx, f, []string{EventFrameNavigation},\n\t\tfunc(data any) bool {\n\t\t\tif navEvt, ok := data.(*NavigationEvent); ok {\n\t\t\t\t// Check if the navigation URL matches the pattern\n\t\t\t\tmatched, err := matcher(navEvt.url)\n\t\t\t\tif err != nil {\n\t\t\t\t\tmatcherErr = err\n\t\t\t\t\t// Return true here even though it's not correct and no match\n\t\t\t\t\t// was found. We need this to exit asap so that the error can be\n\t\t\t\t\t// propagated to the caller.\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\treturn matched\n\t\t\t}\n\t\t\treturn false","sourceCodeStart":2075,"sourceCodeEnd":2111,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L2075-L2111","documentation":"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.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:2085 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}