Azure/bicep

Bicep linter is flagging a warning on property assignment when it shouldn't

Opened this issue · 0 comments

Bicep version
run bicep --version via the Bicep CLI, az bicep version via the AZ CLI or via VS code by navigating to the extensions tab and searching for Bicep
Image

Describe the bug
I do not expect the below code snippet to generate a linter warning:
Image
But it does:
Image

To Reproduce
Copy the below code in your VSCode Extension

targetScope = 'managementGroup'

var targetManagementGroup = managementGroup().id

param roleDefinitionIds (resource<'Microsoft.Authorization/roleAssignments@2022-04-01'>.properties.roleDefinitionId)[] = []
param policyAssignmentId string

@batchSize(1)
resource policyAssignmentId_targetManagementGroup_roleDefinitionIds 'Microsoft.Authorization/roleAssignments@2022-04-01' = [
  for item in roleDefinitionIds: if (!empty(roleDefinitionIds)) {
    name: guid(policyAssignmentId, targetManagementGroup, item)
    properties: {
      roleDefinitionId: item
      principalType: 'ServicePrincipal'
      principalId: toLower(policyAssignmentIdX.identity.principalId)
    }
  }
]

resource policyAssignmentIdX 'Microsoft.Authorization/policyAssignments@2024-05-01'  existing {
 name: 'placeholder' 
}

Additional context
Notice if I use a param of type 'string' , no linter errors ocurr:
Image