Skip to content

fix: Render empty subscription arrays correctly (#4195) - #140

Open
Omansh5 wants to merge 1 commit into
mainfrom
bug4195-empty-subscription-rendering
Open

fix: Render empty subscription arrays correctly (#4195)#140
Omansh5 wants to merge 1 commit into
mainfrom
bug4195-empty-subscription-rendering

Conversation

@Omansh5

@Omansh5 Omansh5 commented Aug 7, 2026

Copy link
Copy Markdown

Overview/Summary

This PR fixes Bug @#4195(Azure/Azure-Landing-Zones#4195) by correctly rendering empty subscription arrays for optional platform subscriptions in the generated Bicep parameter files.

Previously, when the Identity or Security subscription IDs were left empty, the generated .bicepparam files contained:

subscriptionsToPlaceInManagementGroup: ['']

This PR updates the rendering logic so that empty subscription values are rendered as:

subscriptionsToPlaceInManagementGroup: []

while preserving valid subscription IDs.

This PR fixes/adds/changes/removes

  1. Updates the Bicep file rendering logic in modules/file_manipulation/locals.bicep.tf.
  2. Converts subscriptionsToPlaceInManagementGroup: [''] to subscriptionsToPlaceInManagementGroup: [] after template rendering.
  3. Preserves valid subscription IDs and arrays.
  4. Scopes the replacement specifically to subscriptionsToPlaceInManagementGroup so unrelated [''] values are not modified.

Validation

Validation was performed using the ALZ Accelerator with the following configuration:

    • IaC: Bicep
  • Management subscription: Configured
  • Connectivity subscription: Configured
  • Identity and Security subscriptions: Tested with both empty and individually empty configurations

Verified that:

  • Both Identity and Security empty → subscriptionsToPlaceInManagementGroup: [].
  • Only Identity empty → empty subscription array is rendered as [].
  • Only Security empty → empty subscription array is rendered as [].
  • Valid Management and Connectivity subscription IDs are preserved.
  • Multiple valid subscription IDs are preserved unchanged.
  • An unrelated [''] value remains unchanged.

The final rendering therefore removes the invalid empty subscription entry only from the affected parameter while preserving unrelated values.

Fixes #4195

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 addresses Bug #4195 by adjusting the Bicep .bicepparam templating pipeline to render empty subscription arrays as [] (instead of ['']) after template rendering, while leaving populated subscription arrays unchanged.

Changes:

  • Post-processes rendered .bicepparam content to convert [''] to [].
  • Keeps the existing escaping/unescaping flow around templatestring() intact.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Omansh5 Omansh5 changed the title Fix Bug #4195: Render empty subscription arrays correctly fix: Render empty subscription arrays correctly (#4195) Aug 7, 2026
@Omansh5
Omansh5 force-pushed the bug4195-empty-subscription-rendering branch from 0f031e1 to f120a30 Compare August 12, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants