Surface ARM deployment root cause with actionable hints#6801
Surface ARM deployment root cause with actionable hints#6801spboyer wants to merge 1 commit intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds root cause identification and actionable guidance for ARM deployment errors. When deployments fail, azd now attempts to identify the deepest error code in the nested error tree and provides targeted hints for 10 common ARM error codes. This addresses issue #6795, which notes that ARM errors represent 45.26% of all azd errors.
Changes:
- Added
armErrorHintsmap with user guidance for 10 common ARM error codes - Added
RootCause()andRootCauseHint()methods to surface the most specific error and provide actionable guidance - Updated
Error()method to append hints when available - Added 7 new tests covering various error tree structures
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cli/azd/pkg/azapi/azure_deployment_error.go | Added hint map, RootCause/RootCauseHint methods, and findDeepestError helper to identify and provide guidance for root causes |
| cli/azd/pkg/azapi/azure_deployment_error_test.go | Added unit tests for root cause detection and hint retrieval functionality |
| cli/azd/pkg/azapi/testdata/arm_sample_error_01.txt | Updated expected output to include hint for Conflict error code |
Comments suppressed due to low confidence (2)
cli/azd/pkg/azapi/azure_deployment_error_test.go:174
- This test does not verify which error code is returned when multiple branches exist at different depths. It should assert that the deepest error (AuthorizationFailed at depth 2) is returned, not just that some non-empty code is returned. This would have caught the bug in findDeepestError where it returns the last error encountered rather than the deepest one. Add: require.Equal(t, "AuthorizationFailed", root.Code)
func Test_RootCause_MultipleBranches(t *testing.T) {
err := &AzureDeploymentError{
Details: &DeploymentErrorLine{
Code: "",
Inner: []*DeploymentErrorLine{
{
Code: "Conflict",
Inner: []*DeploymentErrorLine{
{Code: "AuthorizationFailed"},
},
},
{
Code: "ValidationError",
},
},
},
}
root := err.RootCause()
require.NotNil(t, root)
require.NotEmpty(t, root.Code)
}
cli/azd/pkg/azapi/azure_deployment_error.go:42
- The hint suggests using 'az vm list-usage' which is specific to VM quotas, but InsufficientQuota errors can occur for many Azure resource types (Storage, Networking, etc.). Consider a more generic hint like "Your subscription has insufficient quota for this resource type. Check your quotas in the Azure portal or request an increase." This avoids suggesting a VM-specific command that may not apply to the actual quota issue.
"InsufficientQuota": "Your subscription has insufficient quota. Check usage with 'az vm list-usage --location <region>' or request an increase in the Azure portal.",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2cc05e7 to
4ed2cbd
Compare
Add RootCause() method to AzureDeploymentError that finds the deepest error code in the ARM error tree. Add RootCauseHint() with guidance for the top-10 most common ARM error codes. Display hints in deployment error output to help users resolve failures faster. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4ed2cbd to
06a790a
Compare
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Summary
Adds root cause identification and actionable guidance to ARM deployment errors. When a deployment fails, azd now highlights the deepest error code and provides targeted hints for the top-10 most common ARM error codes.
Fixes #6795
Changes
azure_deployment_error.go
azure_deployment_error_test.go
Data Context
ARM errors account for 45.26% of all azd errors (~57,956). This improves UX by surfacing root cause with actionable next steps.