Skip to content

fix: update regex for powerbi_embedded to enforce lowercase and remov…#199

Closed
asensionacher wants to merge 1 commit into
Azure:masterfrom
asensionacher:master
Closed

fix: update regex for powerbi_embedded to enforce lowercase and remov…#199
asensionacher wants to merge 1 commit into
Azure:masterfrom
asensionacher:master

Conversation

@asensionacher

Copy link
Copy Markdown

Fixes #166

Changed regex for powerbi_embedded

Copilot AI review requested due to automatic review settings December 30, 2025 08:30
@asensionacher

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread resourceDefinition.json
"regex": "^(?=.{3,63}$)[a-z][a-z0-9]*$",
"scope": "region",
"slug": "pbi",
"dashes": true

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"dashes": true
"dashes": false

Copilot uses AI. Check for mistakes.
Comment thread resourceDefinition.json
"max": 63
},
"regex": "^(?=.{3,63}$)(?!.*--)[a-zA-Z0-9][a-zA-Z0-9-]+$",
"regex": "^(?=.{3,63}$)[a-z][a-z0-9]*$",

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread main.tf
max_length = 63
scope = "region"
regex = "^[a-zA-Z0-9][a-zA-Z0-9-]+$"
regex = "^[a-z][a-z0-9]*$"

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}$.

Suggested change
regex = "^[a-z][a-z0-9]*$"
regex = "^[a-z][a-z0-9]{2,62}$"

Copilot uses AI. Check for mistakes.
Comment thread main.tf
max_length = 63
scope = "region"
regex = "^[a-zA-Z0-9][a-zA-Z0-9-]+$"
regex = "^[a-z][a-z0-9]*$"

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread main.tf
max_length = 63
scope = "region"
regex = "^[a-zA-Z0-9][a-zA-Z0-9-]+$"
regex = "^[a-z][a-z0-9]*$"

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
regex = "^[a-z][a-z0-9]*$"
regex = "^[a-z][a-z0-9-]*$"

Copilot uses AI. Check for mistakes.
@asensionacher asensionacher closed this by deleting the head repository May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PowerBI Embedded regex incorrect

2 participants