Repository navigation
fix: raise Error instead of assert for user input validation - #3245
Open
Pavel Feldman (pavelfeldman) wants to merge 1 commit into
Open
Pavel Feldman (pavelfeldman) wants to merge 1 commit into
Pavel Feldman (pavelfeldman) wants to merge 1 commit into
Conversation
Pavel Feldman (pavelfeldman)
marked this pull request as ready for review
October 12, 2026 21:59
Devin Rousso (dcrousso)
approved these changes
Oct 13, 2026
Dmitry Gozman (dgozman)
approved these changes
Oct 13, 2026
This branch has not been deployed
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.
Several checks on user input used
assert, sopython -Ostripped them. For example,request.post(url, data="", form={...})then sent the request and droppedformwithout telling the caller. Without-O, these checks raisedAssertionError, which isn't a PlaywrightError.This turns every user-facing
assertin_implintoraise Error(...)and keeps the messages. That covers:APIRequestContext.fetch: the first argument must be a URL or aRequest; only one ofdata/form/multipart; non-negativemax_redirects/max_retries; form file payloads must have abytesbuffer.strregex patterns are supported.MULTILINE/IGNORECASE/DOTALLare supported.to_have_text/to_contain_textwith a list: the expected value must be a list or tuple.The
asserts that check internal invariants (channel state, transport,_soft_scopenesting) are unchanged.Tests: the existing tests for these messages now expect
Error. They fail onmainbecause it raisesAssertionError, and they pass with this change, both normally and underpython -O. The neighbouring fetch, evaluate, assertions and interception suites pass, async and sync.Fixes: microsoft/playwright#43281