Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.27k stars 755 forks source link

Experimental extendableParamFiles does not work with non-scalar values #14654

Open tehho opened 4 months ago

tehho commented 4 months ago

Bicep version Bicep CLI version 0.29.47 (132ade51bc)

Describe the bug When param is of type userdefined type we get a error. Message: Internal Error - System.ArgumentException: Unable to determine parent of specified node of type 'ObjectSyntax' at span '[24:41]' because it has not been indexed.

To Reproduce main.bicep

type typeFoo = {
  test: string
}

param foo typeFoo

output test string = foo.test

test.bicepparam

using 'main.bicep'

extends 'shared.bicepparam'

shared.bicepparam

using none

param foo = {
  test: 'bar'
}

bicepconfig.json

{
  "experimentalFeaturesEnabled": {
    "extendableParamFiles": true
  }
}

Additional context If shared.bicepparam only contains primitives and test.bicepparam contains objects it works

stephaniezyen commented 4 months ago

Quoting @jeskew from #14656 :

User-defined types are supported in bicepparam files. Looking at the example from the original issue, if you use a scalar UDT, there is no unhandled exception:

main.bicep

@minLength(10)
type constrainedString = string

param strParam constrainedString

output test string = strParam

shared.bicepparam

using none

param strParam = 'xxxxxxxxxx'

test.bicepparam

using 'main.bicep'

extends 'shared.bicepparam'

Conversely, when there is no UDT, template authors will still run into the same error behavior when a non-scalar value is supplied:

main.bicep

param objectParam object

output test object = objectParam

shared.bicepparam

using none

param objectParam = {
  property: 'value'
}

test.bicepparam

using 'main.bicep'

extends 'shared.bicepparam'
nduijvelshoff commented 2 months ago

Any update on this bug?