Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Exception Calling GetBicepResources #2739

Closed
oZakari opened this issue Jan 27, 2025 · 3 comments
Closed

[BUG] Exception Calling GetBicepResources #2739

oZakari opened this issue Jan 27, 2025 · 3 comments
Assignees
Labels
downstream An issue for downstream tracking of PSRule repositories

Comments

@oZakari
Copy link

oZakari commented Jan 27, 2025

Description of the issue

Creating a subscription placement module for the Bicep registry.

Tests are failing with exception during PSRule.

Error messages

https://github.com/oZakari/bicep-registry-modules/actions/runs/12997174362/job/36247590993

Error: Failed to expand bicep source '/home/runner/work/bicep-registry-modules/bicep-registry-modules/avm/ptn/mgmt-groups/subscription-placement/tests/e2e/defaults/main.test.bicep'. Exception calling "GetBicepResources" with "2" argument(s): "Unable to expand resources because the source file '/home/runner/work/bicep-registry-modules/bicep-registry-modules/avm/ptn/mgmt-groups/subscription-placement/tests/e2e/defaults/main.test.bicep' was not valid. An error occurred evaluating expression '[format('subPlacment-{0}{1}', uniqueString(parameters('parSubscriptionPlacement')[copyIndex()].managementGroupId), copyIndex())]' line 16682. The argument 'baseString' for 'UniqueString' is not a valid string."

Reproduction

Run the tests locally within the Bicep Registry Module

Version of PSRule

2.9.0

How are you running PSRule

GitHub Actions

Additional context

No response

@oZakari oZakari added the Needs: Triage 🔍 Needs attention from the team. label Jan 27, 2025
Copy link
Contributor

Thanks for raising your first issue, the team appreciates the time you have taken 😉

@BernieWhite
Copy link
Member

@oZakari Thanks for logging the issue. I have been able to trace the issue back to a bug in PSRule for Azure.

However I also found this block of code in avm\ptn\mgmt-groups\subscription-placement\modules\helper.bicep:

@description('Output of the Management Group and Subscription Resource ID placements.')
output subscriptionPlacements array = [
  for (subscription, i) in subscriptionIds: {
    name: '${managementGroupId}/${subscription}'
  }
]

After inspecting the code it seems that managementGroupId is the resource ID of the management group instead of the name, causing a secondary issue that by my understanding would need to be resolved in the code of the module. Are able to double check this and let me know if you disagree with my analysis. Thanks.

I'll create a downstream issue on https://github.com/Azure/PSRule.Rules.Azure for the resolution that will ship in the next patch release, estimated next week.

@BernieWhite BernieWhite self-assigned this Feb 1, 2025
@BernieWhite BernieWhite added upstream An issue for upstream tracking of PSRule dependencies downstream An issue for downstream tracking of PSRule repositories and removed Needs: Triage 🔍 Needs attention from the team. upstream An issue for upstream tracking of PSRule dependencies labels Feb 1, 2025
@BernieWhite
Copy link
Member

Fixed in PSRule for Azure release v1.41.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
downstream An issue for downstream tracking of PSRule repositories
Projects
None yet
Development

No branches or pull requests

2 participants