Azure / Azure/bicep

Providing a way for extension users to enforce linting errors when the type.json schema is not respected

Open
#17,463 1 comment 0 reactions 1 assignee Claimed by @shenglol View on GitHub
enhancement Local Deploy
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Is your feature request related to a problem? Please describe.**

Whenever an Azure resource has a missing property, an error is returned by the compiler providing the list of properties that should be present.

```bicep
// Returns BCP035 Error
// The specified "resource" declaration is missing the following required properties: "kind", "location", "name", "sku". If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues.
resource storage_res 'Microsoft.Storage/storageAccounts@2024-01-01' = {
}
```

However, when using extension types, the error becomes a warning which could easily be ignored or missed by the user when not using an extension like `Error Lens` in VSCode.

```bicep
extension kubernetes with {
namespace: ''
kubeConfig: 'ddd'
}

// Returns BCP035 Warning
// The specified "resource" declaration is missing the following required properties: "metadata". If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues.
// Yellow squiggly lines needs to be hovered or the problem tab needs to be opened and read
resource namespace_res 'core/Namespace@v1' = {

}
```

Allowing the compilation of this bicep file that does not respect the type schema will often lead to runtime errors and loss of development time to fix the issue after the fact.

**Describe the solution you'd like**
There should be a way to enforce that required properties on extension types should be present to allow the compilation of the bicep file.

Either through the original compiler error by upgrading it's level to error so that it is in line with Azure resources.

Or through a new linter rule with a default `error` level to allow users who are happy with the current behaviour to disable the enforcement.

Edit: After doing some tests on my own extensions, I noticed that the problem only affects the MsGraph and Kubernetes extensions. So perhaps this is actually a problem specific to only those two extensions?

Edit2: It seems that the behaviour is not consistent within resources of the same extension. These three resource types are within the same extension and only the third does not return an error for the missing required properties

![Image](https://github.com/user-attachments/assets/29d38c10-54af-4620-9c90-9f84fdf63597)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.