fix(glob): throw on page.route() for unbalanced braces in glob patterns#40442
Open
Thavamani13 wants to merge 2 commits intomicrosoft:mainfrom
Open
fix(glob): throw on page.route() for unbalanced braces in glob patterns#40442Thavamani13 wants to merge 2 commits intomicrosoft:mainfrom
Thavamani13 wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Validates glob patterns eagerly in RouteHandler and WebSocketRouteHandler
constructors so an invalid pattern like '{foo' throws immediately when
page.route() / context.route() is called, rather than silently aborting
requests at match time via a SyntaxError from new RegExp().
Fixes: microsoft#40422
Skn0tt
reviewed
Apr 27, 2026
| constructor(baseURL: string | undefined, url: URLMatch, handler: WebSocketRouteHandlerCallback) { | ||
| this._baseURL = baseURL; | ||
| this.url = url; | ||
| if (isString(url)) |
Member
There was a problem hiding this comment.
let's move this to the dispatcher / server side, so it also applies to our language ports.
Move glob pattern validation from the client-side WebSocketRouteHandler constructor to setWebSocketInterceptionPatterns in both BrowserContext and Page dispatchers, so the error also surfaces for language ports.
Contributor
Test results for "tests 1"9 flaky41467 passed, 847 skipped Merge workflow run. |
Contributor
Test results for "MCP"1 failed 6651 passed, 927 skipped Merge workflow run. |
yury-s
reviewed
Apr 27, 2026
| this._baseURL = baseURL; | ||
| this._times = times; | ||
| this.url = url; | ||
| if (isString(url)) |
Member
There was a problem hiding this comment.
_updateInterceptionPatterns is called next line at both constructions sites and it does the glob validation on the server, do we still need to duplicate the logic here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
globToRegexPattern()now throws a descriptive error for nested{, unmatched}, and unclosed{RouteHandlerandWebSocketRouteHandlerconstructors callresolveGlobToRegexPattern()eagerly so the error surfaces immediately whenpage.route()/context.route()is called, not silently at request-match timeFixes #40422