Skip to content

fix(auth): update browser command arguments for Windows and clean URL… - #55

Merged
Cesar-M-Diaz merged 6 commits into
mainfrom
mafe/fix-windows
Aug 4, 2026
Merged

fix(auth): update browser command arguments for Windows and clean URL…#55
Cesar-M-Diaz merged 6 commits into
mainfrom
mafe/fix-windows

Conversation

@mafesernaarboleda

@mafesernaarboleda mafesernaarboleda commented Aug 3, 2026

Copy link
Copy Markdown
Member

… in tests

Summary by CodeRabbit

  • Bug Fixes
    • Improved Windows browser launching for OAuth URLs containing spaces or special characters.
    • Preserved existing browser-launch behavior on macOS and Linux.
    • Added validation to prevent invalid URLs from launching a browser.
    • Improved Windows compatibility when starting remote MCP services, including hidden console windows and safer command resolution.
    • Preserved URL, header, and argument handling across supported platforms.
  • Tests
    • Added coverage for browser launching, MCP startup behavior, platform differences, and URL validation.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

openBrowser is now exported. Windows browser launching uses rundll32.exe url.dll,FileProtocolHandler. MCP wrappers use validated Windows paths, encoded payloads, and platform-specific fallback commands. Tests cover these changes.

Changes

Cross-platform process launching

Layer / File(s) Summary
Platform browser launcher update
packages/core/src/auth/auth-manager.ts, packages/core/test/unit/auth/open-browser.test.ts, packages/core/test/integration/auth/auth-manager.test.ts
openBrowser is exported. Windows uses rundll32.exe url.dll,FileProtocolHandler. Tests cover platform commands, URL validation, URL forwarding, error logging, and Windows path handling.
MCP wrapper bootstrap and fallback
scripts/mcp-wrapper.js, scripts/plugin-generators.mjs, package.json
MCP wrappers use an encoded Windows bootstrap, trusted npx.cmd resolution, validated cmd.exe paths, and platform-specific fallback commands. mcp-remote version 0.1.38 is added as a runtime dependency.
MCP wrapper validation
packages/core/test/unit/mcp/mcp-wrapper.test.ts
Tests verify bootstrap resolution, argument boundaries, encoded Windows payloads, rejected root-relative system paths, and trusted executable selection.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: cesar-m-diaz

Poem

A rabbit checks the browser path,
rundll32.exe avoids a mishap.
Encoded MCP data hops with care,
Trusted commands run everywhere.
Tests guard each route.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the Windows browser argument changes and URL cleanup described in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mafe/fix-windows

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/auth/auth-manager.ts`:
- Line 22: Update the Windows launch flow around execFile to resolve
%SystemRoot%\System32\rundll32.exe and pass that absolute path instead of the
bare executable name. Handle a missing SystemRoot by logging the launch failure
and returning before invoking execFile, and update both affected Windows test
assertions to expect the resolved path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a73a00bc-0bc4-4967-a657-fdd9be6a402a

📥 Commits

Reviewing files that changed from the base of the PR and between a7073e3 and 3293a40.

📒 Files selected for processing (3)
  • packages/core/src/auth/auth-manager.ts
  • packages/core/test/integration/auth/auth-manager.test.ts
  • packages/core/test/unit/auth/open-browser.test.ts

Comment thread packages/core/src/auth/auth-manager.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/mcp-wrapper.js`:
- Around line 118-119: Update the npx launch logic in scripts/mcp-wrapper.js at
lines 118-119 to invoke cmd.exe on Windows with argument-safe quoting,
preserving boundaries for the URL and header values; keep direct npx execution
on non-Windows platforms. Apply the same generated-launcher change in
scripts/plugin-generators.mjs at lines 262-263, and add a Windows test covering
a URL with query parameters.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 806e3e29-cb15-4131-b0ce-14a0a11517cf

📥 Commits

Reviewing files that changed from the base of the PR and between 3293a40 and 1138cff.

📒 Files selected for processing (2)
  • scripts/mcp-wrapper.js
  • scripts/plugin-generators.mjs

Comment thread scripts/mcp-wrapper.js Outdated
@socket-security

socket-security Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedmcp-remote@​0.1.3810010010089100

View full report

Comment thread scripts/mcp-wrapper.js Outdated
const child = spawn(npxBin, ['-y', 'mcp-remote@0.1.38', url, ...headerArgs, '--transport', 'http-first', '--silent'], {
stdio: 'inherit',
env: process.env,
shell: isWin,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Setting shell:true on Windows runs this through cmd.exe /c, so the url (and each --header value) is pasted back into a shell command line instead of staying a separate argv element — which is the exact class of bug the rundll32 change below fixes. Node quotes the args so & is fine, but cmd still expands %VAR% even inside quotes, so a percent-encoded URL (%20, %2F) or an env-looking token in a header value will get mangled. Can we avoid passing the url/headers through the shell?

Comment thread packages/core/src/auth/auth-manager.ts Outdated
if (process.platform === 'win32') {
// Use ShellExecute directly instead of cmd /c start to avoid & being
// interpreted as a command separator on Windows.
execFile('rundll32', ['url.dll,FileProtocolHandler', url], (err) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

rundll32 returns 0 and exits almost immediately even when the FileProtocolHandler can't open anything (no default browser, etc.), so this err branch will essentially never fire and launch failures go silently unlogged on Windows — unlike open/xdg-open which do surface real child-process errors. Is silent failure acceptable here, or should we at least try to detect it?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/test/unit/mcp/mcp-wrapper.test.ts`:
- Around line 77-88: Update the “wrapper preserves argv boundaries outside
Windows” test to skip execution on Windows, since its fixture only creates the
Unix npx executable while Windows resolves npx.cmd. Preserve the existing
assertions and behavior for non-Windows platforms.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f2a7095c-22fd-4b86-987c-69f77d309604

📥 Commits

Reviewing files that changed from the base of the PR and between b46af8e and de17274.

📒 Files selected for processing (6)
  • packages/core/src/auth/auth-manager.ts
  • packages/core/test/integration/auth/auth-manager.test.ts
  • packages/core/test/unit/auth/open-browser.test.ts
  • packages/core/test/unit/mcp/mcp-wrapper.test.ts
  • scripts/mcp-wrapper.js
  • scripts/plugin-generators.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/test/integration/auth/auth-manager.test.ts

Comment thread packages/core/test/unit/mcp/mcp-wrapper.test.ts Outdated
Skip the POSIX npx fixture on Windows and inject the invalid SystemRoot only after Node startup so the wrapper, rather than Node initialization, is under test.
@Cesar-M-Diaz
Cesar-M-Diaz requested a review from EHortua August 4, 2026 15:05
@Cesar-M-Diaz
Cesar-M-Diaz merged commit 8250260 into main Aug 4, 2026
6 checks passed
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.

4 participants