Skip to content

fix(fetch): send empty form and multipart bodies - #3239

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
mainfrom
fix-playwright-43286
Oct 12, 2026
Merged

Pavel Feldman (pavelfeldman) merged 1 commit into
mainfrom
fix-playwright-43286

Conversation

@pavelfeldman

Copy link
Copy Markdown
Member

APIRequestContext checked form and multipart for truthiness, so form={} and multipart={} were skipped and the request went out with no body and no Content-Type. In the Node client {} is truthy, so it sends application/x-www-form-urlencoded for an empty form and an empty multipart/form-data body for an empty multipart.

This checks them for None, like data, and sends an empty form field list for form={}, since object_to_array({}) returns None. The requests are now byte-for-byte what the Node client sends.

Tests: an empty form and an empty multipart reach the server with the right Content-Type (async and sync). The multipart test uses PUT because the Twisted test server rejects an empty multipart POST body before handling it. Both fail without the fix and pass on chromium, firefox and webkit.

Fixes: microsoft/playwright#43286

`form={}` and `multipart={}` were ignored because empty dicts are falsy,
so the request went out without a body or Content-Type. Check for None
instead, like `data`, and match the Node client: an empty form is sent as
application/x-www-form-urlencoded and an empty multipart as an empty
multipart/form-data body.

Fixes: microsoft/playwright#43286
@pavelfeldman
Pavel Feldman (pavelfeldman) marked this pull request as ready for review October 12, 2026 17:35
@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit 3bd3d8a into main Oct 12, 2026
28 of 29 checks passed
@pavelfeldman
Pavel Feldman (pavelfeldman) deleted the fix-playwright-43286 branch October 12, 2026 21:36
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]: Empty form={} and multipart={} are ignored in Python APIRequestContext

2 participants