[py] fix add_request_handler ignoring url_patterns on callback= path#17666
[py] fix add_request_handler ignoring url_patterns on callback= path#17666titusfortner wants to merge 1 commit into
Conversation
Code Review by Qodo
1. Dict patterns match everything
|
PR Summary by QodoFix BiDi Network.add_request_handler callback= path to honor url_patterns WalkthroughsDescription• Ensure callback= request handlers fall back to url_patterns when event is omitted. • Prevent unscoped intercepts that previously matched every request. • Add regression test asserting urlPatterns are sent to network.addIntercept. Diagramgraph TD
A["Caller code"] --> B["Network.add_request_handler"] --> C["Dispatch: patterns = event ?? url_patterns"] --> D["RequestHandlers.add_handler"] --> E["BiDi: network.addIntercept"] --> F["Browser"]
High-Level AssessmentThe chosen fix is the simplest and most consistent approach: it makes the callback= (keyword) dispatch path behave like the positional path by ensuring patterns are derived from url_patterns when event is None. Considered alternatives (e.g., signature/overload restructuring) would be more invasive for minimal additional value. File ChangesBug fix (1)
Tests (1)
|
f999fc6 to
a2f5b52
Compare
|
Code review by qodo was updated up to the latest commit a2f5b52 |
🔗 Related Issues
💥 What does this PR do?
Fixes the high-level
driver.network.add_request_handler(callback=...)form so it honorsurl_patterns. Previously, passing the handler as a keyword leftevent=None, which dropped the patterns and intercepted every request instead of only the ones the caller scoped.🔧 Implementation Notes
The keyword (
callback=) and positional dispatch paths are now consistent — when no positional event is given, the intercept falls back tourl_patterns.🤖 AI assistance
🔄 Types of changes