Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ? on output forces usage of language version 2 #15145

Closed
Tracked by #14190
slavizh opened this issue Sep 25, 2024 · 1 comment
Closed
Tracked by #14190

Using ? on output forces usage of language version 2 #15145

slavizh opened this issue Sep 25, 2024 · 1 comment
Assignees

Comments

@slavizh
Copy link
Contributor

slavizh commented Sep 25, 2024

Bicep version
Bicep CLI version 0.30.3 (2f0e78d)

Describe the bug
I am logging this as bug as I was not expecting this behavior.

To Reproduce
So I had the following scenario. I have Bicep template that has output. The output is of type string. The output value is assigned via resource property. We have found out that the property sometimes can be null. When the value null is passed this fails the deployment as the value of the output needs to be string and cannot be null. The solution was to add ? after string and that way we could allow the value to be null. But turned out as soon as you add ? it converts the ARM template to language version 2. I was not aware that using ? at that place turns it to language version 2. Because of language version 2 that broke the usage of existing syntax as there are a lot of known issues with using existing syntax and language version 2 (#13674 and #13937). The simplest way to reproduce is below:

main.bicep

param foo string = ''

output bar string = foo

this generates to language version 1.

param foo string = ''

output bar string? = empty(foo) ? null : foo

this generates to language version 2.

Additional context
Add any other context about the problem here.

@jeskew
Copy link
Member

jeskew commented Oct 16, 2024

Behaving as intended. User-defined types (including nullable types) are only compatible with language version 2.0.

@jeskew jeskew closed this as completed Oct 16, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Bicep Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants