[Claimed #3422] fix(extension): keep empty response header values on HTTP/2

Merged
GI
13d ago
+92-7

Mirrored from external contributor PR #3422 after approval by @shrey150.

Original author: @aryansahai22
Original PR: https://github.com/browserbase/stagehand/pull/3422
Approved source head SHA: 3bfc4a715f9798e2ee44ded4a9d01e2d354d88a5

@aryansahai22, please continue any follow-up discussion on this mirrored PR. When the external PR gets new commits, this same internal PR will be marked stale until the latest external commit is approved and refreshed here.

Original description

why

Fixes #3421.

Over HTTP/2, a response header sent with an empty value disappears from response.headersArray(). headerValue() then returns null and headerValues() returns [], even though headers() and allHeaders() report the header as "" on the same response. Over HTTP/1.1 all of them agree.

what changed

  • splitHeaderValues() in packages/extension/understudy/response.ts no longer filters out empty values. That was the only place the value was lost: headersArray() falls back to the header map when Chrome sends no raw header text, which is the case for HTTP/2.
  • Two regression tests in packages/extension/tests/response-rpc.test.ts:
    • one drives response.headers_array through the RPC router for a header map with an empty value, before and after extra info arrives and next to a duplicated header;
    • one asserts the header-map path and the raw-text path report the same entries.
  • Patch changeset for the extension and the TypeScript and Python SDKs, as other extension-only fixes use.

No protocol or SDK code changes. Both SDKs already return "" for a present empty value once the runtime includes it in response.headers_array.

test plan

  • vitest run packages/extension/tests packages/extension/understudy: 73 files, 1190 tests pass. Both new tests fail without the source change.
  • tsc --noEmit -p packages/extension/tsconfig.json, plus oxfmt --check and oxlint on the changed files: clean.
  • Manual check against Chrome 156 with the node:http2 fixture from the issue. Before: headerValue('x-empty') is null and the header is missing from headersArray(). After: "" and present, matching HTTP/1.1.
  • packages/sdk-ts/tests/integration/pageGotoResponse.test.ts still passes against the rebuilt extension.
  • Not run: the Python and Go checks, since I don't have uv or go installed. The change touches no generated code and no protocol schema.

One note for whoever runs just check: scripts/release/check-changesets.ts currently fails on main because of agent-discoverability-metadata.md. The changeset added here validates on its own.


Summary by cubic

Fixes HTTP/2 responses dropping headers sent with an empty value from headersArray(), which made headerValue() return null and headerValues() return [] even though headers() reported the header as "". HTTP/1.1 responses already reported the header consistently across all methods.

  • Removes the empty-value filter in splitHeaderValues(), the only place the value was lost when Chrome sends no raw header text.
  • Adds regression tests covering header-map entries with empty values, extra-info arrivals, duplicated headers, and parity between the header-map and raw-text paths.
  • Adds patch changesets for the extension, TypeScript SDK, and Python SDK.