Repository navigation
fix(extension): keep empty response header values on HTTP/2 - #3422
aryansahai22 wants to merge 1 commit into
Conversation
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 detectedLatest commit: 3bfc4a7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
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 |
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
shrey150
left a comment
There was a problem hiding this comment.
Thanks for the clear repro! Verified this matches Playwright's behavior for empty header values over both HTTP/1.1 and HTTP/2 — approving.
…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>
|
The mirrored PR #3437 has been merged into |
…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]>
why
Fixes #3421.
Over HTTP/2, a response header sent with an empty value disappears from
response.headersArray().headerValue()then returnsnullandheaderValues()returns[], even thoughheaders()andallHeaders()report the header as""on the same response. Over HTTP/1.1 all of them agree.what changed
splitHeaderValues()inpackages/extension/understudy/response.tsno 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.packages/extension/tests/response-rpc.test.ts:response.headers_arraythrough the RPC router for a header map with an empty value, before and after extra info arrives and next to a duplicated header;No protocol or SDK code changes. Both SDKs already return
""for a present empty value once the runtime includes it inresponse.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, plusoxfmt --checkandoxlinton the changed files: clean.node:http2fixture from the issue. Before:headerValue('x-empty')isnulland the header is missing fromheadersArray(). After:""and present, matching HTTP/1.1.packages/sdk-ts/tests/integration/pageGotoResponse.test.tsstill passes against the rebuilt extension.uvorgoinstalled. The change touches no generated code and no protocol schema.One note for whoever runs
just check:scripts/release/check-changesets.tscurrently fails onmainbecause ofagent-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 madeheaderValue()returnnullandheaderValues()return[]even thoughheaders()reported the header as"". HTTP/1.1 responses already reported the header consistently across all methods.splitHeaderValues(), the only place the value was lost when Chrome sends no raw header text.Written for commit 3bfc4a7. Summary will update on new commits.