fix(fetch): use identity check for data/form/multipart mutual exclusion - #3219
Open
Ashraf Ali (ashrafiucse) wants to merge 1 commit into
Open
Ashraf Ali (ashrafiucse) wants to merge 1 commit into
Ashraf Ali (ashrafiucse) wants to merge 1 commit into
Conversation
The mutual-exclusivity validation in APIRequestContext._inner_fetch()
used truthiness ((1 if data else 0)), so any falsy but supplied data
value ("", b"", 0, [], {}, False) bypassed the check when combined with
form or multipart. Body selection then used `data is not None`, which
treated the falsy data as supplied and silently dropped the form/multipart
payload — the request was sent with an empty/JSON body and no error.
Mirror the Node.js client semantics (options.data === undefined ? 0 : 1,
packages/playwright-core/src/client/fetch.ts) by counting an option as
specified when it is not None. This also rejects data together with an
empty form/multipart, matching Node. Empty form/multipart alone remain
allowed and send no fields, and data="" alone still sends an empty body.
Fixes microsoft/playwright#43059
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.
Summary
APIRequestContext._inner_fetch()used truthiness, so any falsy but supplieddatavalue ("",b"",0,[],{},False) combined withformormultipartpassed validation — then body selection (data is not None) took thedatabranch and silently dropped the form/multipart payload, sending an empty body with no error.None, mirroring the Node.js client semantics (options.data === undefined ? 0 : 1inpackages/playwright-core/src/client/fetch.ts). This also rejectsdatatogether with an emptyform/multipart, matching Node;form={}alone remains allowed and sends no fields, anddata=""alone still sends an empty body.data×form/multipart) plus empty-form/multipart parity cases.Fixes microsoft/playwright#43059