Fix apiVersionToFloat crashing on preview API versions with a sub-version - #1511
Open
Allan Oliveira (allan-oliveira) wants to merge 1 commit into
Open
Conversation
…sion
apiVersion.replace('-preview', '') only strips the literal "-preview"
substring, leaving a dangling ".N" suffix for versions like "7.1-preview.1"
(becomes "7.1.1"), which float() can't parse. Split on "-preview" instead
and keep only the part before it, so any preview sub-version is dropped
along with the marker.
Fixes Azure#946, Azure#1454
Allan Oliveira (allan-oliveira)
requested review from
UnyieldingAvocado,
Bhavesh Bhati (bhaveshbhati),
mishrarish and
v-anvashist
as code owners
August 6, 2026 22:33
Author
|
@microsoft-github-policy-service agree |
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.
Summary
az devops invoke --api-version <X.Y-preview.N>fails withcould not convert string to float: '<X.Y.N>'.apiVersionToFloatonly strips the literal-previewsubstring:For an input like
7.1-preview.1, this leaves7.1.1behind (the sub-version suffix stays attached), whichfloat()can't parse.Fix
Split on
-previewand keep only the part before it, so the whole preview marker (including any sub-version) is dropped:This is the only call site of
apiVersionToFloatin the codebase, and the parsed float is only used for a local version comparison againstresource_location.max_version(line 91) — the original, unmodifiedapi_versionstring is still passed through unchanged to the actual HTTP client call (line 103), so this only fixes the local comparison logic without touching wire behavior.Test plan
azext_devops/tests/latest/team/test_invoke.pycovering plain versions,X.Y-preview,X.Y-preview.N, and multi-digit sub-versions.Fixes #946
Fixes #1454