Skip to content

fix(python): preserve query parameters in CDP discovery URLs - #3221

Draft
Kayvan-Zahiri wants to merge 1 commit into
browserbase:mainfrom
Kayvan-Zahiri:codex/python-cdp-discovery-query
Draft

Kayvan-Zahiri wants to merge 1 commit into
browserbase:mainfrom
Kayvan-Zahiri:codex/python-cdp-discovery-query

Conversation

@Kayvan-Zahiri

@Kayvan-Zahiri Kayvan-Zahiri commented Oct 16, 2026 •

Copy link
Copy Markdown

An HTTP CDP endpoint such as https://proxy.test/browser/?token=demo is currently probed as https://proxy.test/browser/?token=demo/json/version. The discovery suffix becomes part of the query value, so the resolver polls the wrong URL. A fragment can similarly swallow the suffix.

Build the discovery URL from parsed URL components: append /json/version to the path, preserve the original query (including percent encoding), and omit the fragment. Direct ws:// and wss:// endpoints continue to pass through unchanged.

Added eight regression/control cases. Four query/fragment cases fail before the fix; four plain-HTTP/WebSocket controls already pass. All 62 CDP client tests pass with the fix. Python Ruff lint/format, ty, and git diff --check pass. Tests use a mocked discovery reader and fake sockets; no browser or external service was used. A Python-only patch changeset is included; no protocol/generated code changes.

Developed with AI assistance; reproduced the malformed discovery URLs locally and reviewed the patch and tests. The TypeScript resolver has similar string concatenation; this PR is scoped to the Python SDK.

Full Python suite: 794 passed, 1 skipped, 1 failed because the checkout lacks the built extension manifest. The same test fails on the unmodified base; it is unrelated to this patch. Cross-language just check/just test were not run.


Summary by cubic

Fixes CDP discovery URL construction when the HTTP endpoint has a query string or fragment. Such endpoints were probed with the discovery suffix appended to the query value (e.g. .../browser/?token=demo became .../browser/?token=demo/json/version), so the resolver polled the wrong URL.

  • Builds the discovery URL from parsed URL components, appending /json/version to the path, preserving the query (including percent encoding), and dropping the fragment.
  • ws:// and wss:// endpoints pass through unchanged.
  • Adds regression tests for query/fragment cases and WebSocket passthrough.

Written for commit 8c0f451. Summary will update on new commits.

View guided diff

@changeset-bot

changeset-bot Bot commented Oct 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8c0f451

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

This PR includes changesets to release 1 package
Name Type
@browserbasehq/stagehand-python 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

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 Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant