From 1d9d0e5be00699d81138fb685c45b0bd4437cd6d Mon Sep 17 00:00:00 2001 From: HeyItsGilbert Date: Wed, 29 Jul 2026 03:32:08 +0000 Subject: [PATCH 1/3] fix: PropertySet argument transform crash when -PropertySet omitted Test-FeatureFlag forwards -PropertySet into Test-Condition (which already requires it) via a splat. When -PropertySet was omitted, that forwarded $null was an explicit bind, which fired PropertySetTransformAttribute.Transform(). Its null branch called the argument-less Read-PropertySet, which requires -Name or -FilePath and can never bind, so it always threw a confusing transform error instead of a normal missing-parameter message. - Transform() now returns $null on null input instead of calling the broken, module-function-from-a-class-method Read-PropertySet. - Test-FeatureFlag's -PropertySet is now Mandatory, matching Test-Condition, so a missing value fails fast with PowerShell's standard mandatory-parameter error. Fixes #84 --- CHANGELOG.md | 5 +++++ Gatekeeper/Classes/Property.ps1 | 2 +- Gatekeeper/Public/Test-FeatureFlag.ps1 | 1 + docs/en-US/Test-FeatureFlag.md | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf23883..6c862b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). any `IDictionary` instead of only exact `System.Collections.Hashtable`, so configuration built via `ConvertFrom-Json -AsHashtable` (which returns an `OrderedHashtable`) and other ordered/generic dictionaries bind correctly. +- `PropertySetTransformAttribute` no longer calls the broken, argument-less + `Read-PropertySet` when `-PropertySet` is omitted (that call could never + bind and always threw). `-PropertySet` is now a mandatory parameter on + `Test-FeatureFlag`, matching `Test-Condition`, so the missing value is + reported with a clear mandatory-parameter error instead. (#84) ## [1.0.0] 2026-06-05 diff --git a/Gatekeeper/Classes/Property.ps1 b/Gatekeeper/Classes/Property.ps1 index 85c71fb..afb68a7 100644 --- a/Gatekeeper/Classes/Property.ps1 +++ b/Gatekeeper/Classes/Property.ps1 @@ -186,7 +186,7 @@ class PropertySetTransformAttribute : System.Management.Automation.ArgumentTrans [object] Transform([System.Management.Automation.EngineIntrinsics]$engineIntrinsics, [object] $inputData) { if ($null -eq $inputData) { - return $(Read-PropertySet) + return $null } if ($inputData -is [PropertySet]) { return $inputData diff --git a/Gatekeeper/Public/Test-FeatureFlag.ps1 b/Gatekeeper/Public/Test-FeatureFlag.ps1 index 76f8ed3..b904395 100644 --- a/Gatekeeper/Public/Test-FeatureFlag.ps1 +++ b/Gatekeeper/Public/Test-FeatureFlag.ps1 @@ -36,6 +36,7 @@ [FeatureFlag] [FeatureFlagTransformAttribute()] $FeatureFlag, + [Parameter(Mandatory)] [PropertySet] [PropertySetTransformAttribute()] $PropertySet, diff --git a/docs/en-US/Test-FeatureFlag.md b/docs/en-US/Test-FeatureFlag.md index 3a80470..1ee18af 100644 --- a/docs/en-US/Test-FeatureFlag.md +++ b/docs/en-US/Test-FeatureFlag.md @@ -13,7 +13,7 @@ Checks if the current machine's context will pass the feature flag rules. ## SYNTAX ``` -Test-FeatureFlag [-FeatureFlag] [[-PropertySet] ] [-Context] +Test-FeatureFlag [-FeatureFlag] [-PropertySet] [-Context] [-ProgressAction ] [] ``` @@ -60,7 +60,7 @@ Type: PropertySet Parameter Sets: (All) Aliases: -Required: False +Required: True Position: 2 Default value: None Accept pipeline input: False From b2607210909cba1616faa895d4256bf444a4f257 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Tue, 28 Jul 2026 21:04:02 -0700 Subject: [PATCH 2/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- Gatekeeper/Public/Test-FeatureFlag.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Gatekeeper/Public/Test-FeatureFlag.ps1 b/Gatekeeper/Public/Test-FeatureFlag.ps1 index b904395..39cb275 100644 --- a/Gatekeeper/Public/Test-FeatureFlag.ps1 +++ b/Gatekeeper/Public/Test-FeatureFlag.ps1 @@ -37,6 +37,7 @@ [FeatureFlagTransformAttribute()] $FeatureFlag, [Parameter(Mandatory)] + [ValidateNotNull()] [PropertySet] [PropertySetTransformAttribute()] $PropertySet, From 296d9347af6e30ba27aecb35b8bb823c69d16c60 Mon Sep 17 00:00:00 2001 From: HeyItsGilbert Date: Wed, 29 Jul 2026 04:08:25 +0000 Subject: [PATCH 3/3] fix: correct doubled CR line ending in Test-FeatureFlag.ps1 The Copilot Autofix commit (b260721) inserted [ValidateNotNull()] with a plain LF appended after the file's existing CR, producing a stray \r\r\n on that line instead of matching the file's CRLF convention. --- Gatekeeper/Public/Test-FeatureFlag.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gatekeeper/Public/Test-FeatureFlag.ps1 b/Gatekeeper/Public/Test-FeatureFlag.ps1 index 39cb275..632fe5e 100644 --- a/Gatekeeper/Public/Test-FeatureFlag.ps1 +++ b/Gatekeeper/Public/Test-FeatureFlag.ps1 @@ -37,7 +37,7 @@ [FeatureFlagTransformAttribute()] $FeatureFlag, [Parameter(Mandatory)] - [ValidateNotNull()] + [ValidateNotNull()] [PropertySet] [PropertySetTransformAttribute()] $PropertySet,