Skip to content

fix(fetch): use identity check for data/form/multipart mutual exclusion - #3219

Open
Ashraf Ali (ashrafiucse) wants to merge 1 commit into
microsoft:mainfrom
ashrafiucse:fix-43059
Open

Ashraf Ali (ashrafiucse) wants to merge 1 commit into
microsoft:mainfrom
ashrafiucse:fix-43059

Conversation

@ashrafiucse

Copy link
Copy Markdown
Contributor

Summary

  • The mutual-exclusivity validation in APIRequestContext._inner_fetch() used truthiness, so any falsy but supplied data value ("", b"", 0, [], {}, False) combined with form or multipart passed validation — then body selection (data is not None) took the data branch and silently dropped the form/multipart payload, sending an empty body with no error.
  • Count an option as specified when it is not None, mirroring the Node.js client semantics (options.data === undefined ? 0 : 1 in packages/playwright-core/src/client/fetch.ts). This also rejects data together with an empty form/multipart, matching Node; form={} alone remains allowed and sends no fields, and data="" alone still sends an empty body.
  • Regression tests in both async and sync suites: parametrized falsy-value matrix (data × form/multipart) plus empty-form/multipart parity cases.

Fixes microsoft/playwright#43059

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: APIRequestContext accepts data="" together with form

1 participant