Skip to content

vm-repair: skip extension version check when installed version is null - #10191

Open
EdwinBernal1 wants to merge 1 commit into
Azure:mainfrom
EdwinBernal1:edwin/vm-repair-fix-version-null
Open

vm-repair: skip extension version check when installed version is null#10191
EdwinBernal1 wants to merge 1 commit into
Azure:mainfrom
EdwinBernal1:edwin/vm-repair-fix-version-null

Conversation

@EdwinBernal1

@EdwinBernal1 EdwinBernal1 commented Aug 7, 2026

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes
️✔️ None

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

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install azdev required)
  • My extension version conforms to the Extension version schema

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.json automatically.
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.

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.
Copilot AI lite review requested due to automatic review settings August 7, 2026 15:48
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a None installed version to prevent TypeError and allow commands to proceed.
  • Add a unit regression test covering None installed/available extension versions and warning behavior.
  • Bump extension version to 2.2.3 and add a 2.2.3 HISTORY 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_version compares 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 with packaging.version.Version and 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')
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

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.

3 participants