Repository navigation
[Lab] Fix #31857: az lab vm create: Fix KeyError when the formula omits optional properties - #34473
chessMan (mohitmishra786) wants to merge 1 commit into
Conversation
…rmula omits optional properties The formula returned by the service leaves out properties that are not set, such as tags and artifacts, but the validators read them with plain indexing. Use .get() for these lookups so missing values are left unset.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Thank you for your contribution chessMan (@mohitmishra786)! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change intended to prevent errors from missing optional formula properties.
No open issues 🎉
What changed in this PR
Fixes #31857 by preventing KeyError in az lab vm create --formula when service responses omit optional formula properties.
Changes:
- Uses
.get()for optional formula fields, including VM settings, network configuration, and authentication selection. - Adds regression tests for omitted properties, explicit tags, and copying populated formula values.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/lab/validators.py |
Safely reads optional formula properties. |
src/azure-cli/azure/cli/command_modules/lab/tests/latest/test_lab_validators.py |
Tests missing properties and preservation of supplied formula values. |
Review effort: Balanced
|
@microsoft-github-policy-service agree company="Amadeus" |
|
mansoor sarfraz (@msarfraz) Could you take a look when you have time? It is a small fix in the same formula handling as #34354, which you reviewed. Thanks. |
|
Hi chessMan (@mohitmishra786), |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
🤖 PR Validation — ️✔️ All clear
Related command
az lab vm create --formulaDescription
Fixes #31857.
The formula returned by the service leaves out properties that are not set.
_validate_other_parametersread them with plain indexing, so a formula without tags failed withKeyError: 'tags', and with--tagsit failed on the next missing property,artifacts.This uses
.get()for those lookups, so a missing value leaves the argument unset, the same as when the user does not pass it. The same change is applied toosType,disallowPublicIpAddressandisAuthenticationWithSshKey, which are read the same way later in the same command.Testing Guide
Added unit tests in
test_lab_validators.py:--tags;isAuthenticationWithSshKey.The first and third fail on
devwithKeyError: 'tags'andKeyError: 'isAuthenticationWithSshKey'and pass with this change. All lab tests pass locally (12 passed, 1 skipped; the skip is the same ondev).This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.