Repository navigation
fix(cli): prefix scheme for bare-host URLs in browse open - #3512
Merged
Merged
Conversation
Co-authored-by: Shrey Pandya <[email protected]>
🦋 Changeset detectedLatest commit: 41d7a3d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Architecture diagram
sequenceDiagram
participant User
participant CLI as browse CLI
participant Normalizer as normalizeUrlScheme()
participant Driver as BrowseDriver
participant CDP as CDP/Chrome
User->>CLI: browse open <url>
CLI->>Normalizer: validate & normalize URL
alt Bare host (no scheme) & valid host
alt localhost or 127.0.0.1
Normalizer->>Normalizer: prefix http://
else domain or non-localhost IP
Normalizer->>Normalizer: prefix https://
end
else Already has scheme (http:, https:, file:, about:)
Normalizer->>Normalizer: pass through unchanged
else Invalid URL (contains spaces, no host markers)
Normalizer-->>CLI: return original string
end
Normalizer-->>CLI: normalized URL
CLI->>Driver: open(url)
Driver->>CDP: navigate to URL
alt Valid URL
CDP-->>Driver: navigation success
Driver-->>CLI: page title/url
CLI-->>User: result
else Invalid URL still
CDP-->>Driver: -32000 error
Driver-->>CLI: error
CLI-->>User: failure message
end
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Co-authored-by: Shrey Pandya <[email protected]>
shrey150
commented
Nov 20, 2026
Co-authored-by: Shrey Pandya <[email protected]>
Kylejeong2
approved these changes
Nov 20, 2026
This was referenced Nov 20, 2026
2 tasks done
cursor Bot
pushed a commit
that referenced
this pull request
Nov 26, 2026
Merge origin/main into cursor/fix-remote-session-status-propagation-38a5 Conflicts resolved: - packages/cli/src/lib/driver/remote.ts: Keep PR's extractHttpStatus/extractUpstreamMessage helpers for cause chain extraction and 402/429 handling, incorporate main's removal of redundant JSDoc comments - packages/cli/src/lib/driver/remote.disabled.ts: Keep PR's extractHttpStatus function for consistent httpStatus extraction in disabled stub Changes from main: - locator.filter() feature (#3567) - page-level error classification (#3515) - bare hostname URL fix (#3512) - comment removal cleanup (#3538) - other SDK and CLI improvements Co-authored-by: Shrey Pandya <[email protected]>
shrey150
pushed a commit
that referenced
this pull request
Nov 30, 2026
…tab new (#3585) Mirrored from external contributor PR #3577 after approval by @shrey150. Original author: @embrace897 Original PR: #3577 Approved source head SHA: `f88d77d8ba7d0ebe18b598ded23a928dfda8add0` @embrace897, 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 - Apply `normalizeUrlScheme` to the optional `url` argument in `TabNew.run` (`packages/cli/src/commands/tab/new.ts`), matching `browse open` (#3512). - Preserve `undefined` when no URL is passed and keep explicit schemes (`https://`, `about:blank`, etc.) unchanged. - Add unit tests in `packages/cli/tests/tab-new.test.ts` and a patch changeset for `browse`. Fixes #3574. ## Testing - `pnpm --filter browse exec vitest run tests/tab-new.test.ts tests/normalize-url.test.ts` (21 passed) - `pnpm --filter browse check` (`tsc --noEmit`, 0 errors) - `oxlint` & `oxfmt --check` on changed files (0 warnings, 0 errors) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prefixes bare-host URLs with a scheme in `browse tab new`, matching `browse open` so commands like `browse tab new example.com` resolve correctly. Explicit schemes (for example `https://` or `about:blank`) and calls without a URL are left unchanged. Fixes #3574. <sup>Written for commit f88d77d. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/browserbase/stagehand/pull/3577?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=3577 source-sha=f88d77d8ba7d0ebe18b598ded23a928dfda8add0 claimer=shrey150 --> Co-authored-by: embrace897 <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
why
browse open example.comfails with-32000 Cannot navigate to invalid URLbecause CDP rejects bare hosts without a scheme. This is part of theopen unexpectedfailure bucket (8,139 fails, 1,462 installs over 14 days; open is used by 765 users/day, 60% of CLI DAU). Agents often pass bare hosts likeexample.comorlocalhost:3000.what changed
Adds
normalizeUrlScheme()inpackages/cli/src/lib/normalize-url.tsthat prefixes a scheme when the argument looks like a bare host:https://for domains (e.g.example.com) and non-localhost IPshttp://forlocalhostand127.0.0.1Leaves everything else unchanged so invalid URLs still fail downstream.
test plan
normalizeUrlSchemecoveringexample.com,localhost:3000,127.0.0.1:8080/x,about:blank,file:///x, andnot a url: 13 passedSummary by cubic
Fixes
browse opencrashing when given a bare-host URL likeexample.comorlocalhost:3000. Previously CDP rejected these with-32000 Cannot navigate to invalid URL; now the URL is normalized before navigation by prefixinghttps://for domains and non-localhost IPs, andhttp://forlocalhostand127.0.0.1. Host extraction is case-insensitive and handles query strings and paths. URLs that already have a scheme or don't look like a host are left unchanged, so invalid input still fails downstream.Written for commit 41d7a3d. Summary will update on new commits.