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)
- 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.

Choosing the quick fix makes this change:
```bicep
(isWindowsOS ? windowsConfiguration : json('null'))
```
=>
```bicep
windowsConfiguration: provisionVMAgent
```
... which of course causes a compilation error:

## 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
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