Skip to content

fix(ConditionGroupTransformAttribute): Transform calls [ConditionGroup]::FromJson() which doesn't exist #12

@HeyItsGilbert

Description

@HeyItsGilbert

Summary

ConditionGroupTransformAttribute.Transform attempts to call [ConditionGroup]::FromJson($json) when the input is a string file path. ConditionGroup has no FromJson static method — FeatureFlag and PropertySet both have one, but ConditionGroup was never given one. Any string passed through this transform attribute throws MethodNotFound.

File

Gatekeeper/Classes/FeatureFlag.ps1:234

Reproduction

# Test-Condition has [ConditionGroupTransformAttribute()] on -Condition
Test-Condition -Context $ctx -PropertySet $props -Condition '.\mycondition.json'
# Throws: Method invocation failed because [ConditionGroup] does not contain a
#         static method named 'FromJson'

Fix Options

Option A — Add the missing method to ConditionGroup:

static [ConditionGroup] FromJson([string]$json) {
    $data = ConvertFrom-JsonToHashtable -InputObject $json
    return [ConditionGroup]::new($data)
}

Option B — Remove the string/file-path branch from the transform attribute if loading conditions from standalone files is not a supported use case.

Notes

  • Good first issue
  • Found by Jordan B., Sage Nakamura, Chip Torres, Shawn Wee!-ler, and Glenn

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingralphQueued for the ralph loop

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions