Azure / Azure/bicep

Wrong conversion of dependsOn when item is a variable

Open
#5,622 0 comments 3 reactions 0 assignees View on GitHub
bug Needs: Upvote Quality Sprint story: decompiler
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 2h
Merged PRs (30d)
79

Description

**Bicep version**
Bicep CLI version 0.4.1124 (66c84c8ee5)

**Describe the bug**
When running `az bicep decompile --file template.json`

Given the variable:

```
"keyVaultResourceId": "[resourceId('Microsoft.KeyVault/vaults', parameters('keyVaultName'))]",
```

And a dependency like:

```
"dependsOn": ["[variables('keyVaultResourceId')]"],
```

The error message:

```
Error BCP034: The enclosing array expected an item of type "module[] | (resource | module) | resource[]", but the provided item was of type "string".
```

is shown and the conversion produces:

```
var keyVaultResourceId = keyVaultName_resource.id
...
dependsOn: [
keyVaultResourceId
]
```

**To Reproduce**
See above

**Additional context**
Thanks for the great work on the decompile functionality! It saved us a lot of time.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with `az bicep decompile --file template.json` using the variable and `dependsOn` examples from the report. Trace the decompiler's handling of variable-based dependency items and verify that the output no longer produces the BCP034 error and represents the dependency correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.