fix: update regex for powerbi_embedded to enforce lowercase and remov…#199
fix: update regex for powerbi_embedded to enforce lowercase and remov…#199asensionacher wants to merge 1 commit into
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
This PR updates the regex pattern for powerbi_embedded resource naming to enforce lowercase characters and simplify the validation pattern, addressing issue #166.
Key Changes:
- Removed support for uppercase letters, restricting names to lowercase alphanumeric characters only
- Removed consecutive dash prevention (
(?!.*--)) and dash support from the regex pattern - Simplified the regex from
^(?=.{3,63}$)(?!.*--)[a-zA-Z0-9][a-zA-Z0-9-]+$to^(?=.{3,63}$)[a-z][a-z0-9]*$in resourceDefinition.json - Updated main.tf regex from
^[a-zA-Z0-9][a-zA-Z0-9-]+$to^[a-z][a-z0-9]*$
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| resourceDefinition.json | Updated powerbi_embedded regex to enforce lowercase-only naming with simplified pattern |
| main.tf | Updated powerbi_embedded regex to match the lowercase-only pattern from resourceDefinition.json |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "regex": "^(?=.{3,63}$)[a-z][a-z0-9]*$", | ||
| "scope": "region", | ||
| "slug": "pbi", | ||
| "dashes": true |
There was a problem hiding this comment.
The new regex does not allow dashes (hyphens), but the "dashes" property is still set to true. This creates an inconsistency where the configuration suggests dashes are allowed, but the regex pattern will reject any names containing dashes. Either update the regex to allow dashes (e.g., ^(?=.{3,63}$)[a-z][a-z0-9-]*$) or change "dashes" to false to match the new regex pattern.
| "dashes": true | |
| "dashes": false |
| "max": 63 | ||
| }, | ||
| "regex": "^(?=.{3,63}$)(?!.*--)[a-zA-Z0-9][a-zA-Z0-9-]+$", | ||
| "regex": "^(?=.{3,63}$)[a-z][a-z0-9]*$", |
There was a problem hiding this comment.
The regex pattern ^[a-z][a-z0-9]*$ uses the * quantifier which matches zero or more characters after the initial letter. This means it will accept single-character names like "a" or "z", which violates the minimum length requirement of 3 characters defined in the length constraints. The regex should enforce the minimum length constraint, for example: ^[a-z][a-z0-9]{2,62}$ to ensure at least 3 characters total (1 initial + 2 more), or keep the lookahead from the original pattern.
| max_length = 63 | ||
| scope = "region" | ||
| regex = "^[a-zA-Z0-9][a-zA-Z0-9-]+$" | ||
| regex = "^[a-z][a-z0-9]*$" |
There was a problem hiding this comment.
The regex pattern is missing the length constraint lookahead that exists in the resourceDefinition.json file. In resourceDefinition.json, the pattern includes (?=.{3,63}$) to enforce the 3-63 character length requirement, but this regex only has ^[a-z][a-z0-9]*$. For consistency and proper validation, this should match the pattern in resourceDefinition.json or use an equivalent constraint like ^[a-z][a-z0-9]{2,62}$.
| regex = "^[a-z][a-z0-9]*$" | |
| regex = "^[a-z][a-z0-9]{2,62}$" |
| max_length = 63 | ||
| scope = "region" | ||
| regex = "^[a-zA-Z0-9][a-zA-Z0-9-]+$" | ||
| regex = "^[a-z][a-z0-9]*$" |
There was a problem hiding this comment.
The regex pattern ^[a-z][a-z0-9]*$ uses the * quantifier which allows zero or more characters after the initial letter. This means single-character names like "a" would be accepted, violating the minimum length of 3 characters specified on line 2014. The regex should enforce the minimum length constraint, for example: ^[a-z][a-z0-9]{2,62}$ to ensure at least 3 characters total.
| max_length = 63 | ||
| scope = "region" | ||
| regex = "^[a-zA-Z0-9][a-zA-Z0-9-]+$" | ||
| regex = "^[a-z][a-z0-9]*$" |
There was a problem hiding this comment.
The regex does not allow dashes (hyphens), but "dashes" is still set to true on line 2012. Additionally, the "name" and "name_unique" fields on lines 2010-2011 use join("-", ...) which inserts dashes between components. This creates a conflict where generated names would contain dashes but the regex would reject them. Either update the regex to allow dashes (e.g., ^[a-z][a-z0-9-]*$), or change "dashes" to false and update the name generation logic to not use dashes.
| regex = "^[a-z][a-z0-9]*$" | |
| regex = "^[a-z][a-z0-9-]*$" |
Fixes #166
Changed regex for powerbi_embedded