From 3b400d8cc4967cab1fb6d9142b17e308bdec051f Mon Sep 17 00:00:00 2001 From: cproudlock Date: Mon, 13 Jul 2026 06:23:56 -0400 Subject: [PATCH] Fix GE-Enforce client kit under PowerShell 7 (header-array coercion) Found by running the kit under pwsh 7 against the live API: Invoke-WebRequest returns header values as string ARRAYS in PS7 (scalars in Windows PowerShell 5.1), so X-Manifest-Version came back as @('1') and [int] on it threw - report build failed. The target scheduled task runs 5.1 (works), but the kit must be robust under PS7 too (target preinstalls PowerShell 7). Coerce ETag and X-Manifest-Version with @(...)[0], a clean scalar in both. Validated end to end on Linux pwsh 7.6.3 against the dev API: fetch (200) -> cache-304 -> report sent -> landed received=true/status=ok. All 4 client scripts parse clean; PSScriptAnalyzer shows only cosmetic warnings (Write-Host in a CLI, intentional log-guard catch). Co-Authored-By: Claude Opus 4.8 --- plugins/geenforce/client/ShopdbEnforceClient.psm1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/geenforce/client/ShopdbEnforceClient.psm1 b/plugins/geenforce/client/ShopdbEnforceClient.psm1 index 18492d6..a84d2d5 100644 --- a/plugins/geenforce/client/ShopdbEnforceClient.psm1 +++ b/plugins/geenforce/client/ShopdbEnforceClient.psm1 @@ -58,11 +58,13 @@ function Sync-ShopdbManifest { -TimeoutSec 30 -ErrorAction Stop if ($response.StatusCode -eq 200) { [System.IO.File]::WriteAllText($manifestPath, $response.Content) - if ($response.Headers.ETag) { - Set-Content -LiteralPath $etagPath -Value $response.Headers.ETag -NoNewline + # PowerShell 7 returns header values as string arrays; 5.1 as scalars. + # @(...)[0] yields a clean scalar in both. + $etag = @($response.Headers['ETag'])[0] + if ($etag) { + Set-Content -LiteralPath $etagPath -Value $etag -NoNewline } - $version = $null - if ($response.Headers['X-Manifest-Version']) { $version = $response.Headers['X-Manifest-Version'] } + $version = @($response.Headers['X-Manifest-Version'])[0] if ($version) { Set-Content -LiteralPath (Join-Path $CacheDir "$Scope.version") -Value $version -NoNewline }