Skip to content

stagehand-python@4.4.1a0.dev1703

@github-actions github-actions tagged this 16 Nov 19:20
Mirrored from external contributor PR #3465 after approval by @shrey150.

Original author: @Kelvin-Waititu
Original PR: https://github.com/browserbase/stagehand/pull/3465
Approved source head SHA: `c008c299ceadac61d672538f6f90bf8b9387e095`

@Kelvin-Waititu, 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
## Summary

Fixes #3464.

`context.cookies("https://sub.example.com/")` returned host-only cookies
for `example.com`, even though those cookies do not apply to the
requested host. Preserve the original domain's leading-dot distinction:
host-only cookies require an exact hostname, while dotted domains also
match subdomains on a dot boundary.

Add focused regression tests for exact hosts, subdomains and nested
subdomains, unrelated suffixes, dotted domain cookies, secure URLs, path
boundaries, and multiple/empty URL filters. Include patch changesets for
the extension and TypeScript/Python SDKs that bundle it. No protocol or
API changes.

## Validation

- Before the production fix: cookie suite had 3 failed / 20 passed; the
failures reproduce host-only cookies matching subdomains.
- After the fix: cookie suite 23 passed.
- Full extension unit suite: 75 files passed; 1,229 tests passed, 9
TODO.
- Extension TypeScript check: `node_modules/.bin/tsc --noEmit -p
packages/extension/tsconfig.json` passed.
- Extension build: `node_modules/.bin/vite build --config
packages/extension/vite.config.ts` passed.
- Targeted oxlint, oxfmt check, changeset validation, and `git diff
--check` passed.

The first broader test run was blocked by sandbox restrictions on local
HTTP listeners and missing build artifacts. After building the extension
and rerunning outside the sandbox, the entire extension suite passed. No
live-browser integration test or full monorepo/Python suite was run.
`pnpm` and `just` were unavailable on PATH, so checks used the installed
workspace executables directly.

<!-- external-contributor-pr:owned source-pr=3465
source-sha=c008c299ceadac61d672538f6f90bf8b9387e095 claimer=shrey150 -->

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes #3464 by correcting cookie domain matching in the extension so
host-only cookies no longer match subdomains they don't apply to.

Previously, `filterCookies` normalized every cookie domain with a
leading dot, causing host-only cookies like `example.com` to be matched
against `sub.example.com`. Now host-only cookies require an exact
hostname match, while dotted domains (`.example.com`) still match
subdomains on a dot boundary.

**Bug Fixes**
- Adds regression tests covering exact hosts, subdomains, nested
subdomains, suffix boundaries, dotted domains, secure URLs, path
boundaries, and multiple/empty URL filters.
- Adds patch changesets for the extension and the TypeScript/Python SDKs
that bundle it.

No protocol or API changes.

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

<a
href="https://cubic.dev/pr/browserbase/stagehand/pull/3468?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/3468?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3468&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: Kelvin-Waititu <kelvinwaititu3@gmail.com>
Assets 2
Loading