Skip to content

fix(mcp): skip workspace folders without a path#310797

Open
utkarshkgithub wants to merge 2 commits intomicrosoft:mainfrom
utkarshkgithub:fix/310371-skip-pathless-workspace-folders
Open

fix(mcp): skip workspace folders without a path#310797
utkarshkgithub wants to merge 2 commits intomicrosoft:mainfrom
utkarshkgithub:fix/310371-skip-pathless-workspace-folders

Conversation

@utkarshkgithub
Copy link
Copy Markdown

Fixes #310371

Problem

watchFolder() calls joinPath(folder.uri, '.cursor', 'mcp.json') without checking if the URI has a path.

In virtual/remote workspace scenarios, folder.uri.path can be empty, causing:
[UriError]: cannot call joinPath on URI without path

Solution

Add a guard to skip workspace folders that do not have a path component.

Changes

  • Added early return in watchFolder() when folder.uri.path is falsy

Testing

  • Verified VS Code runs normally after the change
  • Ensured no crash occurs when workspace folders without paths are processed

Copilot AI review requested due to automatic review settings April 16, 2026 17:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a crash in MCP workspace discovery by avoiding joinPath(...) on workspace folder URIs that have no path component (common in some virtual/remote workspace scenarios).

Changes:

  • Added a guard in watchFolder() to skip workspace folders whose folder.uri.path is empty.

}

private watchFolder(folder: IWorkspaceFolder) {
if(!folder.uri.path){
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

Spacing in the new guard doesn’t match the repo’s TypeScript style (and may trip eslint rules like keyword-spacing/space-before-blocks). Please format as if (!folder.uri.path) { ... } (spaces after if, around !, and before {).

Suggested change
if(!folder.uri.path){
if (!folder.uri.path) {

Copilot uses AI. Check for mistakes.
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.

[Error] [UriError]: cannot call joinPath on URI without path — workspaceMcpDiscoveryAdapter

3 participants