Fix GE-Enforce client kit under PowerShell 7 (header-array coercion)
All checks were successful
CI / backend (push) Successful in 1m38s
CI / naming (push) Successful in 1s
CI / frontend (push) Successful in 8s

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 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-07-13 06:23:56 -04:00
parent 8dceb8812f
commit 3b400d8cc4

View File

@@ -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
}