fix(cli): improve error message when deploying Radius types with wrong API version#11557
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the rad deploy UX when a Radius resource type is used with an unsupported/incorrect API version and is consequently misrouted through Azure, producing a misleading “configure an Azure provider” error.
Changes:
- Wrap misleading Azure-related deployment errors with actionable context when the compiled template contains only Radius resource types.
- Add Bicep template helpers to extract and classify resource types (Radius vs non-Radius).
- Add unit tests covering resource type extraction/classification and the deployment error wrapping behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/cli/cmd/deploy/deploy.go | Wraps Azure-related deployment errors with additional context when the template contains only Radius types. |
| pkg/cli/cmd/deploy/deploy_test.go | Adds unit tests validating when deployment errors are wrapped vs returned unchanged. |
| pkg/cli/bicep/resources.go | Adds helpers to extract resource types and detect whether a template contains only Radius resource types. |
| pkg/cli/bicep/resources_test.go | Adds unit tests for resource type extraction and Radius-namespace classification. |
willdavsmith
left a comment
There was a problem hiding this comment.
thanks for the contribution! added a couple of comments
30aa590 to
c309c98
Compare
c309c98 to
5ff6b46
Compare
willdavsmith
left a comment
There was a problem hiding this comment.
Looks pretty good to me. Can you address the copilot comments and add sign-offs to the commits to resolve DCO?
474b2a1 to
cf1a623
Compare
|
Addressed the remaining review feedback in |
…g API version When a Bicep template uses a Radius resource type with an unsupported API version (e.g., Radius.Core/applications@2023-10-01-preview), the Bicep compiler cannot resolve the type and treats it as a passthrough ARM resource. The deployment engine then routes it through Azure, producing a misleading error: "Azure deployment failed, please ensure you have configured an Azure provider." This change detects the mismatch between the error (Azure-related) and the template contents (Radius-only resource types) and wraps the error with a clear, actionable message that suggests checking the API version for each resource type. Changes: - Add ExtractResourceTypes, IsRadiusResourceType, and HasOnlyRadiusResourceTypes helpers to pkg/cli/bicep/resources.go - Add addDeploymentErrorContext to the deploy command to detect and contextualize misleading Azure errors for Radius-only templates - Add comprehensive unit tests for all new functions Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Match on the exact Deployment Engine error pattern instead of hardcoding "azure" in string matching. Change resource type namespace list to use Applications.* and Radius.* patterns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
b2203af to
4a6ebae
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11557 +/- ##
==========================================
+ Coverage 51.40% 51.45% +0.05%
==========================================
Files 699 699
Lines 44036 44119 +83
==========================================
+ Hits 22638 22703 +65
- Misses 19244 19253 +9
- Partials 2154 2163 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Description
When a Bicep template uses a Radius resource type with an unsupported API version (e.g.,
Radius.Core/applications@2023-10-01-preview), the Bicep compiler cannot resolve the type and treats it as a passthrough ARM resource. The deployment engine then routes it through Azure, producing a misleading error:This is confusing because the user intended to deploy a Radius resource, not an Azure resource. The actual problem is that the API version is wrong for the given resource type namespace.
This change detects the mismatch between the error (Azure-related) and the template contents (Radius-only resource types) and wraps the error with a clear, actionable message that suggests checking the API version for each resource type. After this change, users will see:
Changes
pkg/cli/bicep/resources.go: AddExtractResourceTypes,IsRadiusResourceType, andHasOnlyRadiusResourceTypeshelpers for template resource type analysispkg/cli/cmd/deploy/deploy.go: AddaddDeploymentErrorContextto detect and contextualize misleading Azure errors for Radius-only templatespkg/cli/bicep/resources_test.go: Add comprehensive unit tests for resource type extraction and classificationpkg/cli/cmd/deploy/deploy_test.go: Add unit tests for the error context wrapping logicType of change
Fixes: #11462
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: