{"record":{"id":"dc2af14a1fc53296","repo":"grafana/k6","slug":"creating-url-matcher-for-path-s-w","errorCode":null,"errorMessage":"creating url matcher for path %s: %w","messagePattern":"creating url matcher for path (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":1375,"sourceCode":"\treturn nm.extraHTTPHeaders[\"referer\"]\n}\n\n// Route registers a handler to be executed for a given request path\nfunc (p *Page) Route(path string, cb RouteHandlerCallback, rm RegExMatcher) error {\n\tp.logger.Debugf(\"Page:Route\", \"sid:%v path:%s\", p.sessionID(), path)\n\n\tp.routesMu.Lock()\n\tdefer p.routesMu.Unlock()\n\tif len(p.routes) == 0 {\n\t\terr := p.mainFrameSession.updateRequestInterception(true)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tmatcher, err := newPatternMatcher(path, rm)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating url matcher for path %s: %w\", path, err)\n\t}\n\n\trouteHandler := NewRouteHandler(path, cb, matcher)\n\t// Append new route at the beginning of the slice as, when several routes match the given pattern,\n\t// they will run in the opposite order to their registration.\n\tp.routes = append([]*RouteHandler{routeHandler}, p.routes...)\n\n\treturn nil\n}\n\n// Unroute removes the route(s) for the specified URL pattern.\n// If multiple routes match the same URL pattern, all of them are removed.\nfunc (p *Page) Unroute(path string) error {\n\tp.logger.Debugf(\"Page:Unroute\", \"sid:%v path:%s\", p.sessionID(), path)\n\n\tp.routesMu.Lock()\n\tdefer p.routesMu.Unlock()\n","sourceCodeStart":1357,"sourceCodeEnd":1393,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/page.go#L1357-L1393","documentation":"Failure to build the URL matcher while registering a page route: the glob/regex path combined with the RegExMatcher could not be compiled into a pattern matcher. The offending input is the path string passed to page.route().","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/page.go:1370 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a valid glob (e.g. '**/api/**') or a syntactically correct regex for the route path","Escape regex metacharacters when matching literal URLs","Test route patterns against the URLs your test actually requests"],"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"}