Azure / Azure/bicep

Incorrect fix suggested when error is caused by a problem in a variable's object value (wants to fix point of variable's use rather than its definition)

Open
#14,702 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

## Repro
Enter this code:
```bicep
@secure()
param adminPasswordOrKey string
param adminUsername string
param authenticationType string = 'password'
param location string
param vmSize string = 'Standard_D2s_v3'
param vmName string

var isWindowsOS = true
var linuxConfiguration = {
disablePasswordAuthentication: true
ssh: {
publicKeys: [
{
path: '/home/${adminUsername}/.ssh/authorized_keys'
keyData: adminPasswordOrKey
}
]
}
}
var windowsConfiguration = {
provisionVmAgent: 'true'
}

resource vmName_resource 'Microsoft.Compute/virtualMachines@2019-12-01' = {
name: vmName
location: location
identity: {
type: 'SystemAssigned'
}
properties: {
hardwareProfile: {
vmSize: vmSize
}
osProfile: {
computerName: vmName
adminUsername: adminUsername
adminPassword: adminPasswordOrKey
linuxConfiguration: ((authenticationType == 'password') ? null : linuxConfiguration)
windowsConfiguration: (isWindowsOS ? windowsConfiguration : json('null'))
}
storageProfile: {
imageReference: null
}
}
}
```
You get this error: "The property "provisionVmAgent" is not allowed on objects of type "WindowsConfiguration". Did you mean "provisionVMAgent"?"
for this line:
```bicep
windowsConfiguration: (isWindowsOS ? windowsConfiguration : json('null'))
```
And it has a quick fix.
![image](https://github.com/user-attachments/assets/9028a41e-fbf7-460b-83aa-930e4aed6dfc)
Choosing the quick fix makes this change:
```bicep
(isWindowsOS ? windowsConfiguration : json('null'))
```
=>
```bicep
windowsConfiguration: provisionVMAgent
```
... which of course causes a compilation error:
![image](https://github.com/user-attachments/assets/8de759f9-956f-4b0b-8554-9274f14e7e5c)

## EXPECTED
Either provide no quick fix, or the quick fix instead make this change to the windowsConfiguration object:
```bicep
var windowsConfiguration = {
provisionVmAgent: 'true'
}
```
=>
```bicep
var windowsConfiguration = {
provisionVMAgent: 'true'
}
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the Bicep snippet and inspect the quick fix for the property-not-allowed diagnostic. Trace how the diagnostic location is selected when the invalid property is inside a variable's object value. Done means the fix targets the variable definition or is omitted, without producing an invalid rewrite at the variable's use site.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.