Azure / Azure/bicep

Decompiler doesn't generate nullable param in Bicep

Open
#12,476 0 comments 0 reactions 0 assignees View on GitHub
story: decompiler type system
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 4h
Merged PRs (30d)
81

Description

**Bicep version**
0.23.1

**Describe the bug**
Decompile an ARM template with a nullable param doesn't produce a param with nullable syntax in Bicep template.

ARM template to decompile:
```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"languageVersion": "2.0",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.23.1.45101",
"templateHash": "15221823124423828917"
}
},
"parameters": {
"nullableString": {
"type": "string",
"nullable": true
}
},
"resources": []
}
```

| Actual Decompiled Bicep Template | Expected Decompiled Bicep Template |
|--------------|-----------|
| `param nullableString string` | `param nullableString string?` |

Notices there's a `?` at the end of the type `string`

**To Reproduce**
Copy and paste the below ARM template into a json file `test.json`
```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"languageVersion": "2.0",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.23.1.45101",
"templateHash": "15221823124423828917"
}
},
"parameters": {
"nullableString": {
"type": "string",
"nullable": true
}
},
"resources": []
}
```

Run decompile command
`az bicep decompile --file .\test.json`

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Research direction

Create the reported ARM template in test.json and run `az bicep decompile --file .\test.json` to reproduce the behavior. Trace the decompiler's handling of the parameter's `nullable: true` property and add coverage for this input; done means the generated declaration is `param nullableString string?`.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.