From 378665de12e44c3dce163cc6211af6f0bdf194b8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Apr 2026 13:17:52 +0200 Subject: [PATCH 1/4] fix: preserve array values for multi-select custom properties --- .../public/Repositories/GitHubCustomProperty.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/classes/public/Repositories/GitHubCustomProperty.ps1 b/src/classes/public/Repositories/GitHubCustomProperty.ps1 index e00f7e4d0..12ec3b533 100644 --- a/src/classes/public/Repositories/GitHubCustomProperty.ps1 +++ b/src/classes/public/Repositories/GitHubCustomProperty.ps1 @@ -2,14 +2,19 @@ class GitHubCustomProperty { # The name of the custom property. [string] $Name - # The value of the custom property. - [string] $Value + # The value of the custom property. Can be a string or an array of strings for multi-select properties. + [object] $Value GitHubCustomProperty() {} GitHubCustomProperty([PSCustomObject] $Object) { $this.Name = $Object.property_name ?? $Object.propertyName ?? $Object.Name - $this.Value = $Object.value ?? $Object.Value + $rawValue = $Object.value ?? $Object.Value + if ($rawValue -is [System.Collections.IEnumerable] -and $rawValue -isnot [string]) { + $this.Value = [string[]]$rawValue + } else { + $this.Value = $rawValue + } } [string] ToString() { From 34a7dfe805ee41e0f029d8406e0a518f349294f8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Apr 2026 13:49:04 +0200 Subject: [PATCH 2/4] test: add unit tests for GitHubCustomProperty array preservation --- tests/GitHub.Tests.ps1 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index dab477d5a..d61c3bdaf 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -19,6 +19,43 @@ [CmdletBinding()] param() +Describe 'GitHubCustomProperty' { + It 'Preserves array value for multi-select properties' { + $obj = [PSCustomObject]@{ + property_name = 'SubscribeTo' + value = @('Custom Instructions', 'License', 'Prompts') + } + $prop = [GitHubCustomProperty]::new($obj) + $prop.Name | Should -Be 'SubscribeTo' + $prop.Value | Should -BeOfType [string] + $prop.Value | Should -HaveCount 3 + $prop.Value[0] | Should -Be 'Custom Instructions' + $prop.Value[1] | Should -Be 'License' + $prop.Value[2] | Should -Be 'Prompts' + } + + It 'Keeps scalar string value as string' { + $obj = [PSCustomObject]@{ + property_name = 'Type' + value = 'Module' + } + $prop = [GitHubCustomProperty]::new($obj) + $prop.Name | Should -Be 'Type' + $prop.Value | Should -Be 'Module' + $prop.Value | Should -BeOfType [string] + } + + It 'Handles GraphQL-style property names' { + $obj = [PSCustomObject]@{ + propertyName = 'Environment' + value = 'production' + } + $prop = [GitHubCustomProperty]::new($obj) + $prop.Name | Should -Be 'Environment' + $prop.Value | Should -Be 'production' + } +} + Describe 'Auth' { $authCases = . "$PSScriptRoot/Data/AuthCases.ps1" From 9b8a0af4c51f29d496d425331f06d08091fe895e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 1 May 2026 11:51:20 +0200 Subject: [PATCH 3/4] Fix multi-select test assertion: verify Value is [string[]] type directly instead of relying on pipeline enumeration --- tests/GitHub.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index d61c3bdaf..589732e39 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -27,7 +27,7 @@ Describe 'GitHubCustomProperty' { } $prop = [GitHubCustomProperty]::new($obj) $prop.Name | Should -Be 'SubscribeTo' - $prop.Value | Should -BeOfType [string] + $prop.Value -is [string[]] | Should -BeTrue -Because 'multi-select values must be preserved as string arrays' $prop.Value | Should -HaveCount 3 $prop.Value[0] | Should -Be 'Custom Instructions' $prop.Value[1] | Should -Be 'License' From ffa1c008d49be2a875bf66c93a387572cc96dac8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 1 May 2026 12:19:24 +0200 Subject: [PATCH 4/4] Replace mocked GitHubCustomProperty unit tests with API integration test Removed fabricated [PSCustomObject] tests from GitHub.Tests.ps1 and added a real integration test in Repositories.Tests.ps1 that calls Get-GitHubRepositoryCustomProperty against org repositories and validates that multi-select values are preserved as [string[]] arrays. --- tests/GitHub.Tests.ps1 | 39 +----------------------------------- tests/Repositories.Tests.ps1 | 16 +++++++++++++++ 2 files changed, 17 insertions(+), 38 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 589732e39..96f68ff8f 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -19,43 +19,6 @@ [CmdletBinding()] param() -Describe 'GitHubCustomProperty' { - It 'Preserves array value for multi-select properties' { - $obj = [PSCustomObject]@{ - property_name = 'SubscribeTo' - value = @('Custom Instructions', 'License', 'Prompts') - } - $prop = [GitHubCustomProperty]::new($obj) - $prop.Name | Should -Be 'SubscribeTo' - $prop.Value -is [string[]] | Should -BeTrue -Because 'multi-select values must be preserved as string arrays' - $prop.Value | Should -HaveCount 3 - $prop.Value[0] | Should -Be 'Custom Instructions' - $prop.Value[1] | Should -Be 'License' - $prop.Value[2] | Should -Be 'Prompts' - } - - It 'Keeps scalar string value as string' { - $obj = [PSCustomObject]@{ - property_name = 'Type' - value = 'Module' - } - $prop = [GitHubCustomProperty]::new($obj) - $prop.Name | Should -Be 'Type' - $prop.Value | Should -Be 'Module' - $prop.Value | Should -BeOfType [string] - } - - It 'Handles GraphQL-style property names' { - $obj = [PSCustomObject]@{ - propertyName = 'Environment' - value = 'production' - } - $prop = [GitHubCustomProperty]::new($obj) - $prop.Name | Should -Be 'Environment' - $prop.Value | Should -Be 'production' - } -} - Describe 'Auth' { $authCases = . "$PSScriptRoot/Data/AuthCases.ps1" @@ -330,7 +293,7 @@ Describe 'GitHub' { $stamps.Count | Should -BeGreaterThan 0 } It 'Get-GitHubStamp - Each stamp has Name and BaseUrl properties' { - LogGroup "Stamps - Details" { + LogGroup 'Stamps - Details' { Get-GitHubStamp | ForEach-Object { Write-Host ($_ | Format-List | Out-String) $_.Name | Should -Not -BeNullOrEmpty diff --git a/tests/Repositories.Tests.ps1 b/tests/Repositories.Tests.ps1 index ed482b054..c410e1f26 100644 --- a/tests/Repositories.Tests.ps1 +++ b/tests/Repositories.Tests.ps1 @@ -518,6 +518,22 @@ Describe 'Repositories' { } $repos.Count | Should -BeGreaterThan 0 } + It 'Get-GitHubRepositoryCustomProperty - Gets custom properties and preserves value types' -Skip:($OwnerType -ne 'organization') { + LogGroup 'Custom Properties' { + $properties = Get-GitHubRepositoryCustomProperty -Owner $owner -Repository $repoName + Write-Host ($properties | Format-List | Out-String) + } + if ($properties) { + foreach ($prop in $properties) { + $prop.Name | Should -Not -BeNullOrEmpty + if ($prop.Value -is [System.Collections.IEnumerable] -and $prop.Value -isnot [string]) { + $prop.Value -is [string[]] | Should -BeTrue -Because "multi-select values must be preserved as string arrays, got: $($prop.Value.GetType().FullName)" + } else { + $prop.Value | Should -BeOfType [string] + } + } + } + } It 'Set-GitHubRepository - Updates an existing repository' -Skip:($OwnerType -in ('repository', 'enterprise')) { $description = 'Updated description' LogGroup 'Repository - Set update' {