Skip to content

fix(cli): improve error message when deploying Radius types with wrong API version#11557

Open
officialasishkumar wants to merge 5 commits intoradius-project:mainfrom
officialasishkumar:fix/improve-deploy-error-for-wrong-api-version
Open

fix(cli): improve error message when deploying Radius types with wrong API version#11557
officialasishkumar wants to merge 5 commits intoradius-project:mainfrom
officialasishkumar:fix/improve-deploy-error-for-wrong-api-version

Conversation

@officialasishkumar
Copy link
Copy Markdown

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:

"Azure deployment failed, please ensure you have configured an Azure provider with your Radius environment"

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:

Deployment failed with an Azure provider error, but the template only contains Radius resource types.
This commonly happens when a resource type is used with an incorrect or unsupported API version,
causing it to be misrouted. Please verify that each resource uses a supported API version.

For example, Radius.Core types use API version '2025-08-01-preview' and Applications.Core types use '2023-10-01-preview'.

Changes

  • pkg/cli/bicep/resources.go: Add ExtractResourceTypes, IsRadiusResourceType, and HasOnlyRadiusResourceTypes helpers for template resource type analysis
  • pkg/cli/cmd/deploy/deploy.go: Add addDeploymentErrorContext to detect and contextualize misleading Azure errors for Radius-only templates
  • pkg/cli/bicep/resources_test.go: Add comprehensive unit tests for resource type extraction and classification
  • pkg/cli/cmd/deploy/deploy_test.go: Add unit tests for the error context wrapping logic

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).

Fixes: #11462

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
    • Yes
    • Not applicable
  • A design document PR is created in the design-notes repository, if new APIs are being introduced.
    • Yes
    • Not applicable
  • The design document has been reviewed and approved by Radius maintainers/approvers.
    • Yes
    • Not applicable
  • A PR for the samples repository is created, if existing samples are affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
    • Yes
    • Not applicable
  • A PR for the recipes repository is created, if existing recipes are affected by the changes in this PR.
    • Yes
    • Not applicable

@officialasishkumar officialasishkumar requested review from a team as code owners April 5, 2026 18:53
Copilot AI review requested due to automatic review settings April 5, 2026 18:53
@officialasishkumar officialasishkumar requested a deployment to external-contributor-approval April 5, 2026 18:53 — with GitHub Actions Waiting
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@officialasishkumar officialasishkumar requested a deployment to external-contributor-approval April 5, 2026 19:16 — with GitHub Actions Waiting
@willdavsmith willdavsmith self-requested a review April 6, 2026 18:24
Copy link
Copy Markdown
Contributor

@willdavsmith willdavsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution! added a couple of comments

…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>
@officialasishkumar officialasishkumar force-pushed the fix/improve-deploy-error-for-wrong-api-version branch from 30aa590 to c309c98 Compare April 7, 2026 05:56
@officialasishkumar officialasishkumar requested a deployment to external-contributor-approval April 7, 2026 05:56 — with GitHub Actions Waiting
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
@officialasishkumar officialasishkumar force-pushed the fix/improve-deploy-error-for-wrong-api-version branch from c309c98 to 5ff6b46 Compare April 7, 2026 06:06
@officialasishkumar officialasishkumar requested a deployment to external-contributor-approval April 7, 2026 06:06 — with GitHub Actions Waiting
officialasishkumar and others added 2 commits April 7, 2026 21:13
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>
@officialasishkumar officialasishkumar requested a deployment to external-contributor-approval April 7, 2026 21:19 — with GitHub Actions Waiting
@officialasishkumar officialasishkumar requested a deployment to external-contributor-approval April 7, 2026 21:46 — with GitHub Actions Waiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect error message when deploying Radius.Core/Applications with wrong API version

3 participants