microsoft / microsoft/PSRule

[BUG] Bicep Feature: '[Experimental] Runtime values in tags and sku' breaks PSRule

Open
#3,425 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug downstream
Dominant language
C#
Stars
474
Forks
65
Avg merge
22h 25m
Merged PRs (30d)
26

Description

Description of the issue

When using the new experimental feature in Bicep from 0.46.1: https://github.com/Azure/bicep/releases
([Experimental] Runtime values in tags and sku)

resource example 'Microsoft...' = {
   name: 'example'
   location: resourceGroup().location
   sku: {
      name: this.existingResource().?sku.name ?? 'Standard'
   }
   tags: this.existingResource().?tags ?? {}
}

I now always get the following error shown in the error messages.

Error messages

Exception calling "GetBicepParamResources" with "2" argument(s): "Unable to expand resources because the source file '/home/vsts/work/1/s/main.bicep' was not valid. The deployment 'root/2026-08-07_14.45' with symbolic name 'hubResourceGroup' failed. An error occurred evaluating expression '[if(parameters('keepExistingTags'), union(coalesce(tryGet(target('full'), 'tags'), createObject()), parameters('tags')), parameters('tags'))]' line 701 at path 'tags'. The function "target" was not found."

Reproduction

Create a bicep file containing the new function:

resource example 'Microsoft...' = {
   name: 'example'
   location: resourceGroup().location
   sku: {
      name: this.existingResource().?sku.name ?? 'Standard'
   }
   tags: this.existingResource().?tags ?? {}
}
Version of PSRule

2.9.0

How are you running PSRule

Azure DevOps Microsoft Hosted Agent using the latest version of Linux, running in a PowerShell task using the latest version of bicep (0.46.1)

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the supplied Bicep resource on PSRule 2.9.0 and inspect the GetBicepParamResources path around evaluation of the target expression in tags. Done means the experimental runtime-values example is processed without the "target" function error, with regression coverage for this reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.