Skip to content

Commit 64bf87a

Browse files
spboyerCopilot
andauthored
Add Container Apps and ARM error suggestions (#7250)
* Add Container Apps and ARM error suggestions (#7249) Add InvalidTemplateDeployment rule with container app pattern matching and InvalidResourceGroupLocation rule for region mismatch errors. Enhance ContainerAppOperationError suggestion with revision list command and networking/scaling guidance. Improve RoleAssignmentExists suggestion with retry guidance. Fixes #7249 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review: fix CLI command formatting in CA suggestion Use >- block scalar to avoid line breaks splitting CLI commands. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add rules for specific Container Apps error codes from telemetry Added error suggestion rules for 5 additional Container Apps error codes surfaced in telemetry analysis (per @spboyer review comment): - ContainerAppInvalidName (45 errors, 455s avg wait) - ManagedEnvironmentNotReadyForAppCreation (15 errors) - ManagedEnvironmentInvalidName (12 errors) - InvalidEnvironmentId (14 errors) - MaxNumberOfEnvsExceeded (quota errors) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7f7ba63 commit 64bf87a

File tree

2 files changed

+612
-456
lines changed

2 files changed

+612
-456
lines changed

cli/azd/pkg/errorhandler/pipeline_test.go

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ func TestPipeline_RBACErrors(t *testing.T) {
532532
{
533533
name: "RoleAssignmentExists",
534534
code: "RoleAssignmentExists",
535-
wantMessage: "A role assignment with this configuration already exists.",
535+
wantMessage: "A role assignment already exists for this identity.",
536536
},
537537
{
538538
name: "PrincipalNotFound",
@@ -583,6 +583,83 @@ func TestPipeline_NoSubscriptionsFound(t *testing.T) {
583583
assert.NotEmpty(t, result.Links, "Should include documentation links")
584584
}
585585

586+
func TestPipeline_InvalidTemplateDeployment_ContainerApp(t *testing.T) {
587+
pipeline := NewErrorHandlerPipeline(nil)
588+
589+
// Should match: InvalidTemplateDeployment with "container app" in message
590+
err := &testDeploymentError{
591+
Details: &testErrorDetails{
592+
Code: "InvalidTemplateDeployment",
593+
},
594+
Title: "container app configuration is invalid",
595+
}
596+
597+
result := pipeline.ProcessWithRules(
598+
context.Background(),
599+
err,
600+
[]ErrorSuggestionRule{
601+
{
602+
ErrorType: "testDeploymentError",
603+
Properties: map[string]string{"Details.Code": "InvalidTemplateDeployment"},
604+
Patterns: []string{"container app", "containerapp"},
605+
Message: "The Container Apps deployment template is invalid.",
606+
Suggestion: "Check your Bicep/ARM template.",
607+
},
608+
},
609+
)
610+
require.NotNil(t, result)
611+
assert.Equal(t, "The Container Apps deployment template is invalid.", result.Message)
612+
613+
// Should NOT match: InvalidTemplateDeployment without CA keywords
614+
errNonCA := &testDeploymentError{
615+
Details: &testErrorDetails{
616+
Code: "InvalidTemplateDeployment",
617+
},
618+
Title: "storage account configuration error",
619+
}
620+
621+
resultNonCA := pipeline.ProcessWithRules(
622+
context.Background(),
623+
errNonCA,
624+
[]ErrorSuggestionRule{
625+
{
626+
ErrorType: "testDeploymentError",
627+
Properties: map[string]string{"Details.Code": "InvalidTemplateDeployment"},
628+
Patterns: []string{"container app", "containerapp"},
629+
Message: "The Container Apps deployment template is invalid.",
630+
Suggestion: "Check your Bicep/ARM template.",
631+
},
632+
},
633+
)
634+
assert.Nil(t, resultNonCA, "Should not match without container app keywords")
635+
}
636+
637+
func TestPipeline_InvalidResourceGroupLocation(t *testing.T) {
638+
pipeline := NewErrorHandlerPipeline(nil)
639+
640+
err := &testDeploymentError{
641+
Details: &testErrorDetails{
642+
Code: "InvalidResourceGroupLocation",
643+
},
644+
Title: "resource group location not supported",
645+
}
646+
647+
result := pipeline.ProcessWithRules(
648+
context.Background(),
649+
err,
650+
[]ErrorSuggestionRule{
651+
{
652+
ErrorType: "testDeploymentError",
653+
Properties: map[string]string{"Details.Code": "InvalidResourceGroupLocation"},
654+
Message: "The resource group location conflicts with the deployment.",
655+
Suggestion: "Use the existing resource group's region or create a new one.",
656+
},
657+
},
658+
)
659+
require.NotNil(t, result)
660+
assert.Equal(t, "The resource group location conflicts with the deployment.", result.Message)
661+
}
662+
586663
func TestErrorSuggestionsYaml_IsValid(t *testing.T) {
587664
// Verify the embedded YAML can be parsed
588665
var config ErrorSuggestionsConfig

0 commit comments

Comments
 (0)