Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Fix VS Code Extension Provision Command - Handle Undefined fsPath

Based on the issue and comments, the problem is that selectedFile.fsPath can 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:

  • Add defensive check in provision.ts before calling getWorkingFolder to validate selectedFile and its fsPath
  • Provide a clear error message when selectedFile is undefined or fsPath is unavailable
  • Include context about what selectedItem is for easier debugging
  • Apply the same pattern to similar command files (deploy.ts, up.ts, down.ts, restore.ts, monitor.ts, packageCli.ts, pipeline.ts) to prevent the same issue
  • Create tests to validate the fix
  • Build and lint the extension to ensure no regressions
  • Address code review feedback - refactor to shared utility function
  • Fix validation to use strict equality check
  • Fix l10n.t() to use single string literal for proper localization compatibility
  • Merge latest changes from main branch (Migrate to use new shared eng package #6600)
  • All changes complete, linting passes, build successful

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 23, 2026 21:40
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>
Copilot AI changed the title [WIP] Fix provision failure with VS Code azd extension Fix VS Code extension commands failing with undefined fsPath in virtual file systems Jan 23, 2026
Copilot AI requested a review from vhvb1989 January 23, 2026 21:47
@vhvb1989 vhvb1989 marked this pull request as ready for review January 23, 2026 22:16
Copilot AI review requested due to automatic review settings January 23, 2026 22:16
Copy link
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

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.

@azure-sdk
Copy link
Collaborator

VSCode Extension Installation Instructions

  1. Download the extension at https://azuresdkartifacts.z5.web.core.windows.net/azd/vscode/pr/6601/azure-dev-0.11.0-alpha.1.vsix
  2. Extract the extension from the compressed file
  3. In vscode
    a. Open "Extensions" (Ctrl+Shift+X)
    b. Click the ...\ menu at top of Extensions sidebar
    c. Click "Install from VSIX"
    d. Select location of downloaded file

@bwateratmsft
Copy link
Contributor

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>
@bwateratmsft
Copy link
Contributor

@copilot with #6600 merged there are more changes that will likely need to be made, especially in regards to linting rules. Please merge from main and fix the resulting lint and other issues that come up.

Copy link
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot with #6600 merged there are more changes that will likely need to be made, especially in regards to linting rules. Please merge from main and fix the resulting lint and other issues that co...

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:

  • update.code.visualstudio.com
    • Triggering command: /opt/hostedtoolcache/node/20.20.0/x64/bin/node node /home/REDACTED/work/azure-dev/azure-dev/ext/vscode/node_modules/.bin/vscode-test (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from bwateratmsft January 27, 2026 17:10
@vhvb1989
Copy link
Member

/check-enforcer evaluate

@vhvb1989 vhvb1989 enabled auto-merge (squash) January 27, 2026 17:41
@vhvb1989 vhvb1989 merged commit 2b6faa6 into main Jan 27, 2026
6 checks passed
@bwateratmsft bwateratmsft deleted the copilot/fix-provision-failure-vscode branch January 27, 2026 17:48
@bwateratmsft bwateratmsft linked an issue Jan 27, 2026 that may be closed by this pull request
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.

Provision failing with VS Code azd extension

5 participants