Azure / Azure/bicep

Resource tags referencing a parameter which is a user-defined data type containing properties with optionality marker yields BCP321.

Open
#15,111 4 comments 0 reactions 1 assignee Claimed by @jeskew View on GitHub
intermediate language Quality Sprint
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 2h
Merged PRs (30d)
79

Description

**Bicep version**
Bicep CLI version 0.30.3

**Describe the bug**
A parameter is declared as a user-defined data type containing properties that are string literals with or without a union type and an optionality marker. When this parameter is referenced by the tags property of a resource declaration the BCP321 warning is displayed for each property with an optionality marker.

**To Reproduce**
Steps to reproduce the behavior:

`main.bicep`

```bicep
targetScope = 'subscription'

type Tags = {
stringLiteral: string
stringLiteralUnionType: ('foo' | 'bar')
stringLiteralOptionalityMarker: string?
stringLiteralUnionTypeOptionalityMarker: ('foo' | 'bar')?
}

param name string
param location string
param tags Tags

resource rg 'Microsoft.Resources/resourceGroups@2024-07-01' = {
name: name
location: location
tags: tags
}
```

```
Expected a value of type "string" but the provided value is of type "null | string".
Expected a value of type "string" but the provided value is of type "'bar' | 'foo' | null".
```

**Additional context**
This issue has only arisen since upgrading to version 0.30.3 of Bicep.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.