Fix API version condition for Microsoft Graph #1437
Merged
+2
−2
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.
Description
Intent: When the
-Graphswitch is used, this line is meant to validate$ApiVersionand default it to'v1.0'if the caller didn't pass a valid Microsoft Graph API version ('v1.0'or'beta'). Since the parameter defaults to'2024-11-01'(an ARM version), this normalization is needed for Graph calls.-orbut should use-and. As written, the expression always evaluates to$true:$ApiVersionvalue-ne 'v1.0'-ne 'beta'-orresult'v1.0'$false$true$true✗'beta'$true$false$true✗'2024-11-01'$true$true$true✓This means
$ApiVersionis always overwritten to'v1.0', making it impossible to use'beta'.Fix: Replace
-orwith-and:This correctly reads: "if the version is neither
'v1.0'nor'beta', default to'v1.0'."Contribution Checklist
Before submitting this PR, please confirm you have completed the following:
/powershell/tests/pester.ps1on your local system.