-
Notifications
You must be signed in to change notification settings - Fork 267
Fix VS Code extension commands failing with undefined fsPath in virtual file systems #6601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes the issue where provision and other commands would fail with "The 'path' argument must be of type string. Received undefined" when used with virtual file systems or certain VS Code contexts. Changes: - Added validation for selectedFile.fsPath before calling getWorkingFolder - Provides clear error messages that include URI scheme and selectedItem type - Suppresses automatic issue reporting since this is a user error - Applied fix to all affected commands: provision, deploy, up, down, restore, monitor, packageCli, and pipelineConfig - Added unit tests for the new validation logic Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Removed unused stub functions that weren't actually being used. Simplified tests to focus on the core validation logic. Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Based on code review feedback: - Extracted duplicated validation logic to validateFileSystemUri() in cmdUtil.ts - Updated all 8 command files to use the shared function - Simplified test assertions - Improved code maintainability by reducing duplication Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Changed condition from `!selectedFile.fsPath` to `selectedFile.fsPath === undefined` to avoid incorrectly rejecting empty string paths which are valid for root directories. Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds defensive validation to prevent Azure Developer CLI VS Code extension commands from crashing when invoked with a non-filesystem URI (e.g., virtual file systems) by ensuring getWorkingFolder() is only called with a URI that has a usable fsPath.
Changes:
- Introduced
validateFileSystemUri()to detect unsupported URI contexts and throw a user-friendly, non-bug error (suppresses auto issue reporting). - Applied the validation to 8 CLI commands prior to calling
getWorkingFolder(). - Added a unit test covering the new failure mode for
provision.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ext/vscode/src/commands/cmdUtil.ts | Adds validateFileSystemUri() and uses it to prevent path.dirname(undefined) crashes. |
| ext/vscode/src/commands/provision.ts | Validates selected URI before resolving working folder. |
| ext/vscode/src/commands/deploy.ts | Validates selected URI before resolving working folder. |
| ext/vscode/src/commands/up.ts | Validates selected URI before resolving working folder. |
| ext/vscode/src/commands/down.ts | Validates selected URI before resolving working folder. |
| ext/vscode/src/commands/restore.ts | Validates selected URI before resolving working folder. |
| ext/vscode/src/commands/monitor.ts | Validates selected URI before resolving working folder. |
| ext/vscode/src/commands/packageCli.ts | Validates selected URI before resolving working folder. |
| ext/vscode/src/commands/pipeline.ts | Validates selected URI before resolving working folder. |
| ext/vscode/src/test/suite/unit/provision.test.ts | Adds unit test ensuring the new validation throws and suppresses issue reporting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
VSCode Extension Installation Instructions
|
|
Agree with this comment from Copilot, otherwise looks good. |
The first argument to vscode.l10n.t() should be a single string literal for proper localization tooling compatibility. Removed string concatenation and used a single multi-line string literal instead. Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Merged main branch in commit 629d7e6. All lint checks pass and build is successful with the new shared eng package and esbuild configuration. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
/check-enforcer evaluate |
Fix VS Code Extension Provision Command - Handle Undefined fsPath
Based on the issue and comments, the problem is that
selectedFile.fsPathcan be undefined when using virtual file systems or when the command is invoked in specific contexts. This causes the error: "The 'path' argument must be of type string. Received undefined"Plan:
provision.tsbefore callinggetWorkingFolderto validateselectedFileand itsfsPathselectedFileis undefined orfsPathis unavailableselectedItemis for easier debuggingdeploy.ts,up.ts,down.ts,restore.ts,monitor.ts,packageCli.ts,pipeline.ts) to prevent the same issue💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.