Skip to content

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

Closed
aryansahai22 wants to merge 1 commit into
browserbase:mainfrom
aryansahai22:aryan/response-empty-header-values
Closed

aryansahai22 wants to merge 1 commit into
browserbase:mainfrom
aryansahai22:aryan/response-empty-header-values

Conversation

@aryansahai22

@aryansahai22 aryansahai22 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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.

Written for commit 3bfc4a7. Summary will update on new commits.

View guided diff

splitHeaderValues() discarded empty values, so a header sent with an empty
value vanished from headersArray() whenever Chrome supplied no raw header
text, which is the case for HTTP/2. headerValue() then returned null and
headerValues() returned [] while headers() and allHeaders() still reported
the header.

Fixes browserbase#3421
@changeset-bot

changeset-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3bfc4a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@browserbasehq/stagehand-extension Patch
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-python Patch
browse Patch
@browserbasehq/stagehand-examples Patch
@browserbasehq/stagehand-integrations-claude-cua-sdk Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/eve Patch
@browserbasehq/stagehand-integrations-gemini-cua-sdk Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-claude-agent-sdk Patch
@browserbasehq/stagehand-integrations-example-claude-code-facade Patch
@browserbasehq/stagehand-integrations-codex-sdk Patch
@browserbasehq/stagehand-integrations-example-codex-facade Patch
@browserbasehq/stagehand-integrations-cursor-sdk Patch
@browserbasehq/stagehand-integrations-example-cursor-facade Patch
@browserbasehq/stagehand-integrations-deepagents-sdk Patch
@browserbasehq/stagehand-integrations-eve-sdk Patch
@browserbasehq/stagehand-integrations-fx-sdk Patch
@browserbasehq/stagehand-integrations-mastra-sdk Patch
@browserbasehq/stagehand-integrations-example-mastra-facade Patch
@browserbasehq/stagehand-integrations-pi-sdk Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Nov 9, 2026

@shrey150 shrey150 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clear repro! Verified this matches Playwright's behavior for empty header values over both HTTP/1.1 and HTTP/2 — approving.

@github-actions github-actions Bot added external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. and removed external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was approved by @shrey150 and mirrored to #3437. All further discussion should happen on that PR.

@github-actions github-actions Bot closed this Nov 10, 2026
shrey150 pushed a commit that referenced this pull request Nov 10, 2026
…HTTP/2 (#3437)

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

Original author: @aryansahai22
Original PR: #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.


<!-- This is an auto-generated description by cubic. -->
---
## 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.

<sup>Written for commit 3bfc4a7.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/browserbase/stagehand/pull/3422?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

<!-- external-contributor-pr:owned source-pr=3422
source-sha=3bfc4a715f9798e2ee44ded4a9d01e2d354d88a5 claimer=shrey150 -->

Co-authored-by: Aryan Sahai <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions Bot added external-contributor:completed The mirrored PR has been merged and the external contributor flow is complete. and removed external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. labels Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The mirrored PR #3437 has been merged into main. This original external contributor PR will stay closed as completed.

shrey150 added a commit that referenced this pull request Nov 20, 2026
…3496)

Changesets merged through a mirrored external contributor PR currently
show `Thanks @github-actions!` in release notes, because the mirror PR
is authored by the bot.

This wraps `@changesets/changelog-github` in `.changeset/changelog.cjs`.
For each changeset, if its commit came from a merged PR authored by
`github-actions[bot]` that carries the `external-contributor-pr:owned
source-pr=` marker, it adds `pr:`, `commit:` and `author:` overrides
pointing at the original PR and its author (read from the GitHub API,
not from the PR body text). Changesets that already have overrides, and
every non-mirrored PR, are left unchanged.

Checked locally against the three pending mirrored changesets (#3463,
#3422, #3465 now credit their authors) and a regular PR (#3450 is
unchanged).

If a GitHub lookup fails, the wrapper logs a warning and falls back to
the default credit, so it can't block a release PR.

Dry run (Nov 19) against the live repo with
`@changesets/changelog-github` 0.7.0: `empty-response-header-values` now
credits #3422 / @aryansahai22, `host-only-cookie-matching` credits #3465
/ @Kelvin-Waititu, a regular changeset (`eve-1-0-upgrade`, #3409) is
unchanged, and a simulated API failure falls back to the default line.

No tests added: the failure mode is attribution in release notes, not
publishing, and the release PR diff shows the output before anything
ships.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes release notes so changesets merged through mirrored external
contributor PRs credit the original author instead of
`github-actions[bot]`.

- Wraps `@changesets/changelog-github` in `.changeset/changelog.cjs` to
detect mirrored PRs via the `external-contributor-pr:owned` marker and
add `pr:`, `commit:`, and `author:` overrides from the GitHub API.
- Takes the last marker occurrence, since the mirror body quotes the
original PR description before the trusted marker.
- Leaves changesets that already have overrides and non-mirrored PRs
unchanged, and falls back to the default credit when the GitHub lookup
fails so a release can't be blocked.

<sup>Written for commit 72b02d0.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/browserbase/stagehand/pull/3496?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/browserbase/stagehand/3496?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3496&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Shrey Pandya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:completed The mirrored PR has been merged and the external contributor flow is complete. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

response.headerValue() reports an empty-valued header as missing on HTTP/2 responses

2 participants