vm-repair: skip extension version check when installed version is null - #10191
Open
EdwinBernal1 wants to merge 1 commit into
Open
vm-repair: skip extension version check when installed version is null#10191EdwinBernal1 wants to merge 1 commit into
EdwinBernal1 wants to merge 1 commit into
Conversation
On Azure CLI 2.87 the installed extension metadata (metadata.json) is missing because newer setuptools no longer generates it, so the extension version resolves to None. check_extension_version() compared a version string against None, raising TypeError and aborting every vm-repair command (all validators call it first). Guard against a null installed/available version so the up-to-date check is skipped instead of crashing. Adds a regression unit test and bumps to 2.2.3 (py312-compat takes 2.2.2). CLI 2.88 fixes the underlying metadata generation.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
microsoft-github-policy-service
Bot
requested a review
from Julie Zhu (yanzhudd)
August 7, 2026 15:48
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the vm-repair Azure CLI extension to avoid crashing on Azure CLI 2.87 when the installed extension version cannot be determined (missing metadata.json), and adds a regression test to cover the None-version scenario. It also bumps the extension version and records the change in release history.
Changes:
- Guard
check_extension_version()against aNoneinstalled version to preventTypeErrorand allow commands to proceed. - Add a unit regression test covering
Noneinstalled/available extension versions and warning behavior. - Bump extension version to
2.2.3and add a2.2.3HISTORY entry.
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 | Adds installed-version None guard in the extension up-to-date check. |
| src/vm-repair/azext_vm_repair/tests/latest/test_repair_utils.py | Adds regression tests for None versions and warning/no-warning behavior. |
| src/vm-repair/setup.py | Bumps extension version to 2.2.3. |
| src/vm-repair/HISTORY.rst | Adds release note for 2.2.3 describing the crash fix. |
Suppressed comments (1)
src/vm-repair/azext_vm_repair/repair_utils.py:255
ext['version'] > installed_versioncompares versions as raw strings and can produce incorrect results (e.g., '2.10.0' is considered less than '2.9.0'). Also, when the available extension entry exists but its version is missing/None, the function currently falls through and logs "does not exist within available extensions", which is misleading. Consider parsing versions withpackaging.version.Versionand returning as soon as the matching available extension is processed (or skipping when its version is missing).
if ext['name'] == extension_name and ext.get('version') and ext['version'] > installed_version:
logger.warning('The %s extension is not up to date, please update with az extension update -n %s', extension_name, extension_name)
return
logger.debug('The extension with name %s does not exist within available extensions.', extension_name)
Comment on lines
+25
to
+28
| try: | ||
| self._run(installed, available) | ||
| except TypeError: | ||
| self.fail('check_extension_version raised TypeError on a None installed version') |
Comment on lines
+33
to
+36
| try: | ||
| self._run(installed, available) | ||
| except TypeError: | ||
| self.fail('check_extension_version raised TypeError on a None available version') |
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
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.
🤖 PR Validation — ️✔️ All clear
On Azure CLI 2.87 the installed extension metadata (metadata.json) is missing because newer setuptools no longer generates it, so the extension version resolves to None. check_extension_version() compared a version string against None, raising TypeError and aborting every vm-repair command (all validators call it first). Guard against a null installed/available version so the up-to-date check is skipped instead of crashing. Adds a regression unit test and bumps to 2.2.3 (py312-compat takes 2.2.2). CLI 2.88 fixes the underlying metadata generation.
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.