Skip to content

fix: reject non-string values in emulate extraHttpHeaders - #3486

Open
zichen0116 wants to merge 1 commit into
ChromeDevTools:mainfrom
zichen0116:fix/emulate-extra-headers-string-values
Open

zichen0116 wants to merge 1 commit into
ChromeDevTools:mainfrom
zichen0116:fix/emulate-extra-headers-string-values

Conversation

@zichen0116

Copy link
Copy Markdown

Fixes #3455.

emulate accepted non-string extraHttpHeaders values (numbers, booleans, nested objects): headerStringTransform only checked that the parsed JSON was an object and then cast it to Record<string, string>, so the values flowed into page.setExtraHTTPHeaders, which expects strings.

This change validates each header value in headerStringTransform, mirroring the existing wsHeaders check in src/config/browser-options.ts: a non-string value now fails validation with Header "<key>" must have a string value. String maps, empty string (clears headers), and the non-object error are unchanged.

Tests: added schema-level tests in tests/tools/emulation.test.ts covering number, boolean, and nested-object values (fail) and an all-string map (pass). Verified locally: tests/tools/emulation.test.ts 45/45 pass, including the 4 new tests; tests/McpServer.test.ts and tests/McpPage.test.ts mock-based tests pass (the only failures there are real-browser tests that need a downloaded Chrome binary, unavailable in this environment).

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.

emulate extraHttpHeaders accepts non-string header values

1 participant