-
Notifications
You must be signed in to change notification settings - Fork 745
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
Nested conditional statements in map() lambda function fail #8782
Comments
+1 |
I believe this is the same issue as #8798 & #8843. I dug into this, and found that the DeploymentEngine has an optimization to cache partial function values when using any of the Unfortunately this is going to require a runtime fix. I have submitted this fix, which will be rolled out in the next ARM release (starting this week). For now, the only thing I can recommend is avoiding using any of |
I am able to use In other words, this works as expected:
... but this doesn't (when the condition is false the
|
@jurjenoskam - just confirmed it's the same issue. I've added a test case to verify this with #9102 |
@anthony-c-martin - any ETA on the release? just hit it with map + contains + ternary. |
Example for this: targetScope = 'subscription'
module test 'inner.bicep' = {
name: 'test'
}
// fails
/*
{
"code": "DeploymentOutputEvaluationFailed",
"message": "Unable to evaluate template outputs: 'mapped1,mapped2'. Please see error details and deployment operations. Please see https://aka.ms/arm-debug for usage details.",
"details": [
{
"code": "DeploymentOutputEvaluationFailed",
"target": "mapped1",
"message": "The template output 'mapped1' is not valid: The language expression property 'one' doesn't exist, available properties are 'two'.."
},
{
"code": "DeploymentOutputEvaluationFailed",
"target": "mapped2",
"message": "The template output 'mapped2' is not valid: The language expression property 'two' doesn't exist, available properties are 'one'.."
}
]
}
*/
//var mapped1 = map(test.outputs.foo, arg => arg.one)
//var mapped2 = map(test.outputs.foo, arg => arg.two)
var mapped1 = map(test.outputs.foo, arg => contains(arg, 'one') ? arg.one : 'placeholder1' )
var mapped2 = map(test.outputs.foo, arg => contains(arg, 'two') ? arg.two : 'placeholder2' )
var mapped2a = map(test.outputs.foo, arg => {
xx: contains(arg, 'two') ? arg.two : 'placeholder2'
})
output mapped1 array = mapped1
output mapped2 array = mapped2
output mapped2a array = mapped2a inner.bicep: targetScope = 'subscription'
output foo array = [
{
one: 'one'
}
{
two: 'two'
}
{
three: 'three'
}
{
four: 'four'
}
] Results: "outputs": {
"mapped1": {
"type": "Array",
"value": [
"one",
"",
"",
""
]
},
"mapped2": {
"type": "Array",
"value": [
"placeholder2",
"",
"",
""
]
},
"mapped2a": {
"type": "Array",
"value": [
{
"xx": "placeholder2"
},
{
"xx": ""
},
{
"xx": ""
},
{
"xx": ""
}
]
} |
This has now been fixed and rolled out globally. Please open a new issue if you are still seeing this (or similar) behavior. |
Bicep version
Bicep CLI version 0.11.1 (030248d)
Describe the bug
A nested conditional statement inside a map() lambda function fails.
When deploying the following template:
The two outputs are expected to be the same, but the outputs are as follows:
Clearly the nested conditional statement fails as soon as the false-value is processed.
To Reproduce
Steps to reproduce the behavior: deploy the above template.
The text was updated successfully, but these errors were encountered: