Skip to content

fix: PropertySet argument transform crash when -PropertySet omitted - #88

Merged
HeyItsGilbert merged 3 commits into
mainfrom
fix/84-propertyset-transform-null
Jul 29, 2026
Merged

fix: PropertySet argument transform crash when -PropertySet omitted#88
HeyItsGilbert merged 3 commits into
mainfrom
fix/84-propertyset-transform-null

Conversation

@HeyItsGilbert

Copy link
Copy Markdown
Owner

Summary

Fixes #84.

Test-FeatureFlag forwards -PropertySet into Test-Condition (which already requires it) via a splat: PropertySet = $PropertySet. When -PropertySet was omitted, that forwarded $null was an explicit bind, which fires PropertySetTransformAttribute.Transform(). Its null branch called the argument-less Read-PropertySet, which requires -Name or -FilePath and can never bind — so instead of a normal missing-parameter message, callers got:

Cannot process argument transformation on parameter 'PropertySet'.
Parameter set cannot be resolved using the specified named parameters.

(Omitting the parameter entirely never triggers Transform at all — this only reproduces once Test-FeatureFlag splats the null value downstream.)

Fix

  • Classes/Property.ps1: PropertySetTransformAttribute.Transform() now returns $null on null input instead of calling the broken, module-function-from-a-class-method Read-PropertySet.
  • Public/Test-FeatureFlag.ps1: -PropertySet is now [Parameter(Mandatory)], matching Test-Condition, so a missing value fails fast with PowerShell's standard mandatory-parameter error/prompt instead of the transform crash.
  • Updated docs/en-US/Test-FeatureFlag.md (Required/syntax) and CHANGELOG.md.

Verification

Reproduced the exact repro from #84, confirmed error changes from the transform crash to Cannot process command because of one or more missing mandatory parameters: PropertySet.; confirmed normal call with -PropertySet supplied still returns the expected result. Full Pester suite: 366 passed, 0 failed, 5 skipped (pre-existing).

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
Copilot AI review requested due to automatic review settings July 29, 2026 03:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a PowerShell argument transformation crash when Test-FeatureFlag is called without -PropertySet, by avoiding transform-time calls into Read-PropertySet and by making the missing-argument failure surface as PowerShell’s standard mandatory-parameter error.

Changes:

  • Updated PropertySetTransformAttribute.Transform() to return $null for null input instead of calling Read-PropertySet with no arguments.
  • Made Test-FeatureFlag -PropertySet mandatory to prevent downstream null-splat binding and to fail fast with a standard missing-parameter error.
  • Updated user-facing documentation and changelog to reflect the new requirement and the fix.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Gatekeeper/Public/Test-FeatureFlag.ps1 Makes -PropertySet mandatory (prevents transform crash via null splat).
Gatekeeper/Classes/Property.ps1 Stops transform-time invocation of Read-PropertySet on null input.
docs/en-US/Test-FeatureFlag.md Updates syntax/Required metadata for -PropertySet.
CHANGELOG.md Documents the bugfix and the behavior change under Unreleased.

Comment thread Gatekeeper/Public/Test-FeatureFlag.ps1
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

Test Results

    4 files    444 suites   14s ⏱️
  377 tests   372 ✅  5 💤 0 ❌
1 484 runs  1 458 ✅ 26 💤 0 ❌

Results for commit b260721.

♻️ This comment has been updated with latest results.

HeyItsGilbert and others added 2 commits July 28, 2026 21:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
@HeyItsGilbert
HeyItsGilbert merged commit 1dcfa8b into main Jul 29, 2026
7 checks passed
@HeyItsGilbert
HeyItsGilbert deleted the fix/84-propertyset-transform-null branch July 29, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PropertySetTransformAttribute calls Read-PropertySet with no arguments, so omitting -PropertySet always fails

2 participants