Repository navigation
fix: validate mutually-exclusive body options under python -O - #3238
Suraj-Self (suraj-self) wants to merge 2 commits into
Conversation
|
Not sure why assert error is gone, also we don't need a test for such a minor use case. |
Thanks for reviewing. The explicit guard is needed because assert statements are removed under python -O. I changed the exception to Playwright's Error to match API validation conventions, but I agree that preserving AssertionError keeps this fix narrower. I'll simplify the change and remove the additional optimization-specific tests. |
|
We might need a larger change that addressees all the user-facing asserts. |
Agreed. This issue exposed one case where user-facing validation is disabled under |
|
I'll close this one since it is just a one-off |
Fixes #43281
Summary
Replaces the
assert-based mutual-exclusion guard inAPIRequestContext._inner_fetch()with an explicit conditional that raisesError.assertstatements are stripped underpython -O, which previouslyallowed conflicting
data/form/multipartarguments to bypassvalidation silently.
Also switches the check to presence semantics (
is not None) so that emptyvalues such as
data=""are counted as provided, consistent with how thevalue is used later in the method.
Tests
test_should_reject_empty_data_with_form(sync + async)to expect
Errorinstead ofAssertionError.test_should_reject_multiple_body_options_under_python_optimization(sync + async), which spawns a child interpreter with
-Oand verifies theguard still raises. Confirmed the new test fails on unpatched
mainandpasses with the fix.