vm-repair: do not quote the az token when invoking nested commands on… - #10220
vm-repair: do not quote the az token when invoking nested commands on…#10220Edwin Bernal Microsoft (EdwinBernal1) wants to merge 2 commits into
Conversation
… Windows Quoting the program name made cmd.exe skip the PATH search, so %~dp0 inside az.cmd no longer resolved to the launcher directory and every nested az call failed with 'Failed to load python executable.' on stdout and an empty stderr. Arguments remain individually quoted, preserving the MSRC 115198 hardening. A failed az call now falls back to stdout, reports the exit code when there is no output, and masks secure parameters instead of raising an empty AzCommandError.
|
Hi Edwin Bernal Microsoft (@EdwinBernal1), |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows-specific regression in the vm-repair extension where nested az invocations failed when az resolves to az.cmd (common on MSI installs), and improves error reporting for failed nested az calls when stderr is empty.
Changes:
- Adjust Windows command construction to avoid quoting the
azexecutable token while keeping per-argument quoting for command-injection hardening. - Improve
AzCommandErrormessages by falling back to stdout, reporting exit codes when there’s no output, and masking secure parameters. - Add regression tests covering Windows quoting behavior and improved error surfacing; bump version and update history.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vm-repair/azext_vm_repair/repair_utils.py | Fixes Windows nested az command-line construction and improves error message surfacing/masking. |
| src/vm-repair/azext_vm_repair/tests/latest/test_nested_az_invocation.py | Adds regression tests for Windows nested invocation behavior and error-message handling. |
| src/vm-repair/setup.py | Bumps extension version to 2.2.5. |
| src/vm-repair/HISTORY.rst | Documents the 2.2.5 regression fix and error-reporting improvements. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Automated sensitive-information remediation ran on this pull request.
Agent Assist does not modify source files. The PR creator must remove or replace each suspected value at the linked line:
If a credential was exposed, rotate or revoke it immediately. Detected values are never copied into this comment. ✅ Confirm the finding · ❌ Dispute the finding GitHub only supports a fixed reaction set, so 👍 represents ✅ and 👎 represents ❌. The bot-created reactions are only poll choices. Posted by agent-assist (autonomous bug-fix pipeline). |
Remove the unused sys import, replace tempfile.mkdtemp() with pytest's tmp_path fixture so the temporary directory is cleaned up automatically, and rename the masking test's sample value so it no longer resembles a credential.
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
🤖 PR Validation — ️✔️ All clear
… Windows
Quoting the program name made cmd.exe skip the PATH search, so %~dp0 inside az.cmd no longer resolved to the launcher directory and every nested az call failed with 'Failed to load python executable.' on stdout and an empty stderr. Arguments remain individually quoted, preserving the MSRC 115198 hardening. A failed az call now falls back to stdout, reports the exit code when there is no output, and masks secure parameters instead of raising an empty AzCommandError.
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
az vm repair create/az vm repair run/az vm repair restore/az vm repair reset-nic/az vm repair repair-and-restore/az vm repair repair-buttonAll of them shell out to a nested
azcall through_call_az_command, so all were affected onWindows where
azresolves to theaz.cmdlauncher.General Guidelines
azdev style <YOUR_EXT>locally? —azdev style vm-repair: PASSED (pylint + flake8)python scripts/ci/test_index.py -qlocally? — OK (9 tests, 2 skipped)bug fix with no command, parameter, or default changes
Additional validation:
azdev linter vm-repair: PASSED, no violationsazdev test vm-repair: 94 passed, 35 skipped (skipped = LiveScenarioTest, not run to avoidcreating Azure resources)
signature
AzCommandError('')) and pass with the fixFor new extensions:
About Extension Publish
src/index.jsonwas not modified. Onlysetup.py(VERSION) andHISTORY.rstwere updated, asrequired.