-
Notifications
You must be signed in to change notification settings - Fork 3.4k
azure-cli: crash when handling InvalidTemplateDeployment (response already consumed) #32952
Copy link
Copy link
Open
Labels
Auto-AssignAuto assign by botAuto assign by botComputeaz vm/vmss/image/disk/snapshotaz vm/vmss/image/disk/snapshotError MessagesPossible-SolutionService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.Similar-Issueact-observability-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Milestone
Description
Title: azure-cli: crash when handling InvalidTemplateDeployment (response already consumed)
Description:
When running az vm create the deployment fails with an ARM error (SkuNotAvailable). While handling the ARM template error the CLI hits an internal exception: "The content for this response was already consumed" which leads to an AttributeError and a RuntimeError. The CLI should surface the ARM inner error instead of crashing while trying to read the consumed response.
Environment:
- OS: macOS
- azure-cli: 2.84.0 (installed via Homebrew)
- Python: 3.13.12
- Command run:
az vm create --resource-group reliabilityLabRG1 --name vm1 --image Ubuntu2204 --admin-username azureuser --generate-ssh-keys
Relevant debug excerpt (tail of ~/az_vm_create_debug.log):
Exception Details: (SkuNotAvailable) The requested VM size for resource 'Following SKUs have failed for Capacity Restrictions: Standard_DS1_v2' is currently not available in location 'eastus'. Please try another size or deploy to a different location or different zone.
Code: SkuNotAvailable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../azure/cli/core/commands/arm.py", line 109, in handle_template_based_exception
raise CLIError(ex.inner_exception.error.message)
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'error'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../requests/models.py", line 926, in text
if not self.content:
^^^^^^^^^^^^
File ".../requests/models.py", line 897, in content
raise RuntimeError("The content for this response was already consumed")
RuntimeError: The content for this response was already consumed
What I expected:
- The CLI should show the ARM inner error (SkuNotAvailable) in a clear, non-failing way and not raise a secondary exception while formatting the message.
Steps to reproduce:
- Ensure
eastussubscription has capacity restrictions forStandard_DS1_v2(or simulate failure by requesting an unavailable SKU). - Run the
az vm createcommand above. - Observe that the CLI crashes with a consumed response error while trying to display the template inner error.
Attachments / Logs:
- Full debug log saved at:
~/az_vm_create_debug.log(tail included above) az --versionoutput included in the debug log
Suggested fix:
- Guard against None
inner_exceptionor already-consumed response when building CLI error messages; prefer to fall back to the HttpResponseError.message or the JSON body captured earlier.
Please let me know if you want the full az_vm_create_debug.log attached; I can paste it or provide a link.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Auto-AssignAuto assign by botAuto assign by botComputeaz vm/vmss/image/disk/snapshotaz vm/vmss/image/disk/snapshotError MessagesPossible-SolutionService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.Similar-Issueact-observability-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that