Skip to content

fix(cli): prefix scheme for bare-host URLs in browse open - #3512

Merged
shrey150 merged 3 commits into
mainfrom
cursor/normalize-url-scheme-8216
Nov 20, 2026
Merged

shrey150 merged 3 commits into
mainfrom
cursor/normalize-url-scheme-8216

Conversation

@shrey150

@shrey150 shrey150 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

why

browse open example.com fails with -32000 Cannot navigate to invalid URL because CDP rejects bare hosts without a scheme. This is part of the open unexpected failure 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 like example.com or localhost:3000.

what changed

Adds normalizeUrlScheme() in packages/cli/src/lib/normalize-url.ts that prefixes a scheme when the argument looks like a bare host:

  • https:// for domains (e.g. example.com) and non-localhost IPs
  • http:// for localhost and 127.0.0.1

Leaves everything else unchanged so invalid URLs still fail downstream.

# before (main)
$ browse open example.com --local --headless
-32000 Cannot navigate to invalid URL

# after (this branch)
$ browse open example.com --local --headless
{
  "title": "Example Domain",
  "url": "https://example.com/"
}

test plan

  • Unit tests for normalizeUrlScheme covering example.com, localhost:3000, 127.0.0.1:8080/x, about:blank, file:///x, and not a url: 13 passed
  • Full CLI test suite: 709 passed
  • Lint and type check: passed
  • Manual verification with local Chrome (output above)
Open in Web Open in Cursor 

Summary by cubic

Fixes browse open crashing when given a bare-host URL like example.com or localhost:3000. Previously CDP rejected these with -32000 Cannot navigate to invalid URL; now the URL is normalized before navigation by prefixing https:// for domains and non-localhost IPs, and http:// for localhost and 127.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.

View guided diff Turn on auto-fix

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 41d7a3d

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

This PR includes changesets to release 1 package
Name Type
browse 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

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/cli/src/lib/normalize-url.ts Resolved
Comment thread .changeset/normalize-bare-host-url.md Resolved
@shrey150
shrey150 merged commit f7d7037 into main Nov 20, 2026
29 checks passed
@shrey150
shrey150 deleted the cursor/normalize-url-scheme-8216 branch November 20, 2026 22:55
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants