[Regression]: APIRequestContext JSON-encodes string data for "application/json;charset=UTF-8" since 1.65 (not in release notes)
Los mantenedores suelen responder en 1 día
@microsoft-playwright-automation ya está trabajando en esto.
Desde el 5/11/2026.
- #43945 de @microsoft-playwright-automation — abierto
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 74/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, playwright, typescript
- Área
- api, documentation
Línea de trabajo
Empieza por la documentación de APIRequestContext sobre la opción data y las notas de la versión 1.65; el issue menciona ambas actualizaciones solicitadas, pero no indica rutas de archivos. Comprueba cómo describen la documentación los cuerpos de tipo string y las notas de la versión los breaking changes; después, aclara el comportamiento del tipo de contenido JSON y menciona Buffer para obtener los bytes exactos. La tarea estará terminada cuando ambas actualizaciones reflejen con precisión el comportamiento notificado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version
1.65.0 (same in 1.66.0-alpha-2026-11-05). Different in 1.64.1.
Steps to reproduce
// repro.mjs — "type": "module", @playwright/test installed
import http from 'node:http';
import { request } from '@playwright/test';
const srv = http.createServer((req, res) => { let b = ''; req.on('data', c => b += c); req.on('end', () => res.end(b)); });
await new Promise(r => srv.listen(0, r));
const url = `http://127.0.0.1:${srv.address().port}/`;
const ctx = await request.newContext();
for (const ct of ['application/json', 'application/json;charset=UTF-8', 'application/json; charset=utf-8', 'Application/JSON', 'application/problem+json']) {
const r = await ctx.post(url, { data: 'plain text', headers: { 'content-type': ct } });
console.log(ct, '->', JSON.stringify(await r.text()));
}
await ctx.dispose(); srv.close();
Expected behavior
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:
application/json -> "\"plain text\""
application/json;charset=UTF-8 -> "plain text"
application/json; charset=utf-8 -> "plain text"
Application/JSON -> "plain text"
application/problem+json -> "plain text"
Actual behavior
In 1.65.0 the JSON content type is matched with parameters and case-insensitively, so the string is now JSON-encoded for these headers too:
application/json -> "\"plain text\""
application/json;charset=UTF-8 -> "\"plain text\""
application/json; charset=utf-8 -> "\"plain text\""
Application/JSON -> "\"plain text\""
application/problem+json -> "plain text"
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": 'withcontent-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
APIRequestContextdatathat 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.Bufferis 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
- Lenguaje dominante
- TypeScript
- Estrellas
- 99.1k
- Forks
- 6.8k
- Merge medio
- 17 h 6 min
- PR fusionados (30 d)
- 306
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/playwright
-
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
microsoft/playwright#43987 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
microsoft/playwright#43986 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Embedded number/range inputs contribute their `value` attribute, not their current value, to accessible namesPosiblemente ocupada @lazerg la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
microsoft/playwright#43984 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 64/100
microsoft/playwright#43983 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
microsoft/playwright#43981 ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/playwright
Issues similares
-
status: needs triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
mastra-ai/mastra#29706 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
lingdojo/kana-dojo#33802 · 1 comentario · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
cloudflare/workerd#8290 ·
Los mantenedores suelen responder en 1 día
-
area: build-and-ci possible-duplicate S3: minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
manaflow-ai/cmux#38889 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
ValentinH/react-easy-crop#670 ·