Azure / Azure/bicep

Improve compile-time validation of the resourceId() function for hard-coded resource types.

Open
#14,662 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue Needs: Upvote
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.**
It's very easy to miss that the number of name segments that has to be provided to the `resourceId()` function has to match the number of type segments in the resource type. It's pretty easy to miss when refactoring existing code or decompiling a template. We ran into this with an internal Bicep file and this was the fix that was needed:
![image](https://github.com/user-attachments/assets/b9ece5c2-a552-4df3-b3c2-1acb8f5087ef)

**Describe the solution you'd like**
In situations where the resource type is hard-coded, it would be great if we could enhance the validation to emit an error for an insufficient number of name segments.

Contributor guide

Open the contributing guide

Research direction

Start at the compile-time validation entry point for resourceId() and inspect how hard-coded resource types and name segments are counted. Done means an insufficient number of name segments produces an error while valid counts continue to pass; add or run focused validation coverage if the repository provides it.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.