Skip to content

Commit 25d0fc1

Browse files
Revert "fix: use startsWith guard for EventHub namespace ID to handle unsubstituted env var literals"
This reverts commit 0364b07.
1 parent c330ad5 commit 25d0fc1

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

infra/main.bicep

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ param existingFabricCapacityName string = ''
7373
// This follows best practices for Event Hub usage.
7474
// ============================================================================
7575

76+
var useExistingEventHubNamespace = !empty(existingEventHubNamespaceId)
7677
// ARM eagerly evaluates both ternary branches at validation time, causing split('', '/')[n]
77-
// to throw index-out-of-bounds when the param is empty. startsWith also handles unsubstituted
78-
// '${ENV_VAR}' literals passed verbatim by az deployment validate (unlike azd which substitutes).
79-
// The nil GUID placeholder is structurally valid for ARM but can never target a real resource.
78+
// to throw index-out-of-bounds when the param is empty. Normalise to a structurally valid
79+
// ARM resource ID using the nil GUID (00000000-...) as subscription — a GUID Azure never
80+
// issues — so scope: resourceGroup(...) passes validation but can never target anything real.
8081
// The module is still gated by if(useExistingEventHubNamespace) and never deploys unless
8182
// a real existing namespace ID is provided.
82-
var useExistingEventHubNamespace = startsWith(existingEventHubNamespaceId, '/subscriptions/')
83-
var _safeEventHubNamespaceId = useExistingEventHubNamespace
84-
? existingEventHubNamespaceId
85-
: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/placeholder/providers/Microsoft.EventHub/namespaces/placeholder'
83+
var _safeEventHubNamespaceId = empty(existingEventHubNamespaceId)
84+
? '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/placeholder/providers/Microsoft.EventHub/namespaces/placeholder'
85+
: existingEventHubNamespaceId
8686
// Extract name, subscription ID, and resource group from the resource ID.
8787
var eventHubNamespaceNameFromId = last(split(_safeEventHubNamespaceId, '/'))
8888
var eventHubNamespaceSubscriptionId = split(_safeEventHubNamespaceId, '/')[2]

0 commit comments

Comments
 (0)