Skip to content

Escaped JSON string fails what-if validation but works in deployment #392

Open
@AndrevdG

Description

@AndrevdG

I ran into a little confusing what-if error for a deployment that loads a JSON file into bicep as part of the deployment. The JSON contained, amongst other things, some escaped JSON (JSON in JSON so to speak). This deployment works fine when you deploy it, but if fails on a what-if.

After condensing the code down further, I managed to reproduce this directly in bicep, without needing to import anything.

module.bicep:

param settings object
output settings object = settings

main.bicep:

var test2 = {test: '[\\"Hello World\\"]'}

module t 'module.bicep' = {
  name: 'myApp'
  params: {
    settings: test2
  }
}

output test object = t.outputs.settings

When trying to run what-if this fails with a 'language expression validation':

Image

Deployment runs without issue however:

Image

It only fails when using the variable as input for a module parameter. If you remove the module and pass the variable directly to the output both what-if and deployment work:

var test2 = {test: '[\\"Hello World\\"]'}

output test object = test2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions