You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a custom rule (PSRule/v1) validating resourcelocks names we receive an unexpected error when PSRule is attempting to compare the name of the lock in the bicep file with the filter in the rule condition of the rule.
When hardcoding the name in the bicep-file of the resource lock and doing the same in the .Rule.Yaml file everything works as expected. However, when the names doesn't match and PSRule is expected to fail, we receive a wrong error-message (Reason:)
Example:
Bicep File:
resourcesubLock'Microsoft.Authorization/locks@2017-04-01' = {
name: 'ResourceLock1'properties: {
level: 'CanNotDelete'notes: 'Prevent deletion of subscription and resources'
}
}
Reason:
- The value 'ResourceLock1' does not start with any of 'CanNotDelete'.
Error output
However we receive the following:
Reason:
- The value 'System.String[]' does not start with any of 'System.String[]'.
It seems to output a string array instead of the exact condition being processed.
To Reproduce
I have attached a small .zip file with my use case, which can be run by running the StartPSRule.ps1 file.
(You'll have to change the paths in the PowerShell Splat after the download)
Module in use and version:
Module: PSRule
Version: [2.9.0]
Captured output from $PSVersionTable:
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Darwin 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocol
Version 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Fyi - @BernieWhite , it seems to be a general issue when outputting the 'Reason'.
I'm also receiving (
| REASON:
| - The value 'System.String[]' does not start with any of 'System.String[]'.
) when I'm attempting to use the rule for deployment Names.
Description of the issue
Using a custom rule (PSRule/v1) validating resourcelocks names we receive an unexpected error when PSRule is attempting to compare the name of the lock in the bicep file with the filter in the rule condition of the rule.
When hardcoding the name in the bicep-file of the resource lock and doing the same in the .Rule.Yaml file everything works as expected. However, when the names doesn't match and PSRule is expected to fail, we receive a wrong error-message (Reason:)
Example:
Bicep File:
Custom Resource Lock Rule:
Expected behaviour
The error we expect to receive is the following:
Error output
However we receive the following:
It seems to output a string array instead of the exact condition being processed.
To Reproduce
I have attached a small .zip file with my use case, which can be run by running the StartPSRule.ps1 file.
(You'll have to change the paths in the PowerShell Splat after the download)
Module in use and version:
Captured output from
$PSVersionTable
:Additional context
Zip file uploaded:
tmp.zip
The text was updated successfully, but these errors were encountered: