Skip to content

Commit 186d66b

Browse files
authored
bicep: Fix panic during deployment progress rendering (#4187)
We had a panic in our display code when rendering data if you were using a the microsoft graph provider in bicep (a new extensibility feature) because some of the properties of the ARM operation object were not present. This change adds additional guards to our rendering logic to ignore operations that don't have a complete set of data. Fixes #4169
1 parent d6813fb commit 186d66b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cli/azd/pkg/infra/azure_resource_manager.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ func (rm *AzureResourceManager) GetDeploymentResourceOperations(
6868
} else {
6969
// Otherwise find the resource group within the deployment operations
7070
for _, operation := range topLevelDeploymentOperations {
71-
if operation.Properties.TargetResource != nil &&
71+
if operation.Properties != nil &&
72+
operation.Properties.TargetResource != nil &&
73+
operation.Properties.TargetResource.ResourceType != nil &&
7274
*operation.Properties.TargetResource.ResourceType == string(AzureResourceTypeResourceGroup) {
7375
resourceGroupName = *operation.Properties.TargetResource.ResourceName
7476
break
@@ -87,10 +89,15 @@ func (rm *AzureResourceManager) GetDeploymentResourceOperations(
8789
// Recursively append any resource group deployments that are found
8890
innerLevelDeploymentOperations := make(map[string]*armresources.DeploymentOperation)
8991
for _, operation := range topLevelDeploymentOperations {
90-
if operation.Properties.TargetResource == nil {
92+
if operation.Properties == nil ||
93+
operation.Properties.TargetResource == nil ||
94+
operation.Properties.TargetResource.ID == nil ||
95+
operation.Properties.TargetResource.ResourceType == nil ||
96+
operation.Properties.ProvisioningOperation == nil {
9197
// Operations w/o target data can't be resolved. Ignoring them
9298
continue
9399
}
100+
94101
if !strings.HasPrefix(*operation.Properties.TargetResource.ID, resourceIdPrefix) {
95102
// topLevelDeploymentOperations might include deployments NOT within the resource group which we don't want to
96103
// resolve

cli/azd/pkg/tools/bicep/bicep.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
// Version is the minimum version of bicep that we require (and the one we fetch when we fetch bicep on behalf of a
2929
// user).
30-
var Version semver.Version = semver.MustParse("0.28.1")
30+
var Version semver.Version = semver.MustParse("0.29.47")
3131

3232
// NewCli creates a new Bicep CLI. Azd manages its own copy of the bicep CLI, stored in `$AZD_CONFIG_DIR/bin`. If
3333
// bicep is not present at this location, or if it is present but is older than the minimum supported version, it is

0 commit comments

Comments
 (0)