microsoft/playwright · error · Error
Unexpected 'data' type
Error message
Unexpected 'data' type
What it means
Error "Unexpected 'data' type" thrown in microsoft/playwright.
Source
Thrown at packages/playwright-core/src/client/fetch.ts:212
// Cannot call allHeaders() here as the request may be paused inside route handler.
const headersObj = options.headers || options.request?.headers();
const headers = headersObj ? headersObjectToArray(headersObj) : undefined;
let jsonData: any;
let formData: channels.NameValue[] | undefined;
let multipartData: channels.FormField[] | undefined;
let postDataBuffer: Buffer | undefined;
if (options.data !== undefined) {
if (isString(options.data)) {
if (isJsonContentType(headers))
jsonData = isJsonParsable(options.data) ? options.data : JSON.stringify(options.data);
else
postDataBuffer = Buffer.from(options.data, 'utf8');
} else if (Buffer.isBuffer(options.data)) {
postDataBuffer = options.data;
} else if (typeof options.data === 'object' || typeof options.data === 'number' || typeof options.data === 'boolean') {
jsonData = JSON.stringify(options.data);
} else {
throw new Error(`Unexpected 'data' type`);
}
} else if (options.form) {
if (globalThis.FormData && options.form instanceof FormData) {
formData = [];
for (const [name, value] of options.form.entries()) {
if (typeof value !== 'string')
throw new Error(`Expected string for options.form["${name}"], found File. Please use options.multipart instead.`);
formData.push({ name, value });
}
} else {
formData = objectToArray(options.form);
}
} else if (options.multipart) {
multipartData = [];
if (globalThis.FormData && options.multipart instanceof FormData) {
const form = options.multipart;
for (const [name, value] of form.entries()) {
if (isString(value)) {View on GitHub (pinned to c8fc3bf8d3)
When it happens
Trigger: Thrown at packages/playwright-core/src/client/fetch.ts:212 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/143326efc93a253b.
Report an issue: GitHub.