Azure / Azure/bicep

Stringifying an array of objects results in an error when its value is passed to another module

Open
#6,167 3 comments 2 reactions 1 assignee Claimed by @alex-frankel View on GitHub
bug intermediate language revisit
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
0.4.1272

**Describe the bug**
Stringifying a locally defined array of objects results in an error about '{' being unexpected. Providing the array through a module does work.

**To Reproduce**
Steps to reproduce the behavior:
```bicep
var myArray = [
{
id: '117'
name: 'John'
}
]

// The module takes a string parameter called 'value'
module tst 'modules/sample-module.bicep' = {
name: 'tst'
params: {
value: string(myArray)
}
}
```

Error is:
```
{'code': 'InvalidTemplate', 'message': 'Deployment template language expression evaluation failed: \'The language expression \'{"id":"117","name":"John"}\' is not valid: the string character \'{\' at position \'0\' is not expected.\'. Please see https://aka.ms/arm-template-expressions for usage details.', 'additionalInfo': [{'type': 'TemplateViolation', 'info': {'lineNumber': 0, 'linePosition': 0, 'path': ''}}]}
```

However, if myArray is part of the output from another module, it does work as expected. So as a workaround I have a, pretty much, empty module returning an array of objects.

**Additional context**
I'm trying to store an array of JSON objects in an App Configuration resource with the application/json content-type.

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.