Azure / Azure/bicep

Misleading error highlight when resource defined in invalid scope

Open
#5,931 0 comments 0 reactions 0 assignees View on GitHub
enhancement error-message
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
VS Code 0.4.1124

**Describe the bug**
Consider the following
```bicep
targetScope='resourceGroup'

resource foo 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: 'blah'
}
```

I'd expect
1. The error highlighting for BCP135 to highlight `Microsoft.Resources/resourceGroups@2021-04-01` rather than the resource body as it is the resource type that's invalid.
2. The `BCP035` error should be supressed - whilst it is true the `location` property is missing, since the resource type is not valid in this scope, adding a `location` is not going to make the template any more valid.

**To Reproduce**
![image](https://user-images.githubusercontent.com/289860/153373997-65f5ce46-1af5-4d07-acb8-a12e0dbda86d.png)

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

Contributor guide

Open the contributing guide

Research direction

No source files or tests are named. Start by reproducing the BCP135 and BCP035 diagnostics with the provided resource-group example, then trace the diagnostic highlighting and validation behavior. Done means BCP135 highlights the resource type and BCP035 is suppressed for this invalid scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.