You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Regression]: APIRequestContext JSON-encodes string data for "application/json;charset=UTF-8" since 1.65 (not in release notes) #43937
Either the 1.64 behavior, or the change to be listed in the release notes. In 1.64.1 only an exact application/json header made Playwright JSON-encode a string data that is not valid JSON:
A string that parses as JSON ('{"a":1}') and a Buffer are sent as is in both versions.
Additional context
The new matching looks more correct, but it silently changes the request body. It is not mentioned in the 1.65 release notes.
What broke for us:
Negative API tests that send a deliberately malformed JSON body as a string (data: '{"a": ' with content-type: application/json;charset=UTF-8). The server now receives a valid JSON string literal instead of a malformed document, so the test checks something else (400 "Syntax error" becomes a different response).
Requests signed with HMAC over the raw body string: the signature is computed over {"a": , but "{\"a\": " is sent, so the server answers 401.
Our workaround is data: Buffer.from(body).
Requests:
Please add this to the 1.65 breaking changes.
Please document in APIRequestContextdata that a string with a JSON content type is sent as is only when it parses as JSON, and is JSON-encoded otherwise. The docs currently read as if strings are always sent as is. Buffer is the way to send exact bytes.
Environment
OS: Linux (mcr.microsoft.com/playwright:v1.65.0-noble)
Node.js: 26.13.0
@playwright/test: 1.65.0
Hi, I'm the Playwright bot. I reproduced this and prepared a documentation fix.
Confirmed in 1.65.0 and current main. The matching change was intentional in #43395, but the release notes and data documentation did not explain its effect on strings. The proposal adds the 1.65 breaking-change entry and documents when strings are JSON-encoded and how to send exact bytes with Buffer. It does not change request behavior.
In 1.64.1 the body is {"a": . In 1.65.0 and main it is "{\"a\": ". Passing Buffer.from('{"a": ', 'utf8') preserves the original body in every version tested.
I checked application/json, application/json;charset=UTF-8, application/json; charset=utf-8, Application/JSON and application/problem+json, each with malformed JSON, a valid JSON string and a Buffer:
Version
Result
1.64.1
Only exact application/json JSON-encodes the malformed string.
1.65.0
All four application/json variants JSON-encode it.
1.66.0-next, main 17ec699e4f4760bab5ad95f6ef9b954d5f1ce7eb
Same as 1.65.0 on Chromium, Firefox and WebKit test projects.
application/problem+json stays raw; valid JSON strings and Buffers are unchanged. These standalone API requests do not use a browser engine.
The change is commit 39ce04859ac1759611967ae76b5c590bf995149d, first released in 1.65.0. Existing request tests and the temporary reproduction passed across all three browser projects: 616 passed, 2 skipped. The build and npm run flint passed.
Activity
github-actions commentedon Nov 5, 2026
microsoft-playwright-automation commentedon Nov 5, 2026
Hi, I'm the Playwright bot. I reproduced this and prepared a documentation fix.
Confirmed in 1.65.0 and current main. The matching change was intentional in #43395, but the release notes and
datadocumentation did not explain its effect on strings. The proposal adds the 1.65 breaking-change entry and documents when strings are JSON-encoded and how to send exact bytes withBuffer. It does not change request behavior.Reproduction and checks
Using the repository server fixture:
In 1.64.1 the body is
{"a":. In 1.65.0 and main it is"{\"a\": ". PassingBuffer.from('{"a": ', 'utf8')preserves the original body in every version tested.I checked
application/json,application/json;charset=UTF-8,application/json; charset=utf-8,Application/JSONandapplication/problem+json, each with malformed JSON, a valid JSON string and a Buffer:application/jsonJSON-encodes the malformed string.application/jsonvariants JSON-encode it.17ec699e4f4760bab5ad95f6ef9b954d5f1ce7ebapplication/problem+jsonstays raw; valid JSON strings and Buffers are unchanged. These standalone API requests do not use a browser engine.The change is commit
39ce04859ac1759611967ae76b5c590bf995149d, first released in 1.65.0. Existing request tests and the temporary reproduction passed across all three browser projects: 616 passed, 2 skipped. The build andnpm run flintpassed.Draft PR: #43945
Triaged on Linux by the Playwright bot - agent run