fix(mcp): skip workspace folders without a path#310797
Open
utkarshkgithub wants to merge 2 commits intomicrosoft:mainfrom
Open
fix(mcp): skip workspace folders without a path#310797utkarshkgithub wants to merge 2 commits intomicrosoft:mainfrom
utkarshkgithub wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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 whosefolder.uri.pathis empty.
| } | ||
|
|
||
| private watchFolder(folder: IWorkspaceFolder) { | ||
| if(!folder.uri.path){ |
There was a problem hiding this comment.
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) { |
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.
Fixes #310371
Problem
watchFolder()callsjoinPath(folder.uri, '.cursor', 'mcp.json')without checking if the URI has a path.In virtual/remote workspace scenarios,
folder.uri.pathcan 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
watchFolder()whenfolder.uri.pathis falsyTesting