@@ -32,15 +32,23 @@ function Invoke-ExecContainerManagement {
3232 }
3333
3434 # Helper: query GHCR for the image at $Tag and return its digest + version label.
35- # The version label is set by the CI build (org.opencontainers.image.version) and contains
36- # the same string as $env:APP_VERSION in the running container — comparing them tells us
37- # whether the channel tag has been republished to a different build.
35+ # The version label is set by the CI build (org.opencontainers.image.version) and matches
36+ # $env:APP_VERSION in the running container — comparing them tells us whether the channel
37+ # tag has been republished to a different build.
3838 function Get-GHCRImageInfo {
3939 param ([string ]$ImageRef , [string ]$Tag )
4040
4141 $imagePath = $ImageRef -replace ' ^ghcr\.io/' , ' ' -replace ' :.*$' , ' '
4242 if (-not $imagePath ) { throw ' Could not parse image path from reference' }
4343
44+ # PS7's Invoke-WebRequest returns .Content as byte[] when the response lacks a charset
45+ # (GHCR manifest media types omit it), so piping straight to ConvertFrom-Json yields
46+ # an int array. Decode bytes first.
47+ function ConvertFrom-RawJson ($Content ) {
48+ if ($Content -is [byte []]) { $Content = [System.Text.Encoding ]::UTF8.GetString($Content ) }
49+ return $Content | ConvertFrom-Json
50+ }
51+
4452 $tokenResp = Invoke-RestMethod - Uri " https://ghcr.io/token?scope=repository:${imagePath} :pull" - Method GET - ErrorAction Stop
4553 $authHeader = @ { Authorization = " Bearer $ ( $tokenResp.token ) " }
4654 $manifestAccept = ' application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json, application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json'
@@ -50,13 +58,13 @@ function Invoke-ExecContainerManagement {
5058 $resp = Invoke-WebRequest - Uri $manifestUri - Method GET - Headers $manifestHeaders - ErrorAction Stop
5159 $digest = $resp.Headers [' Docker-Content-Digest' ]
5260 if ($digest -is [array ]) { $digest = $digest [0 ] }
53- $manifest = $resp.Content | ConvertFrom-Json
61+ $manifest = ConvertFrom-RawJson $resp.Content
5462
5563 if ($manifest.manifests ) {
5664 $child = $manifest.manifests | Where-Object { $_.platform.architecture -eq ' amd64' -and $_.platform.os -eq ' linux' } | Select-Object - First 1
5765 if (-not $child ) { $child = $manifest.manifests | Select-Object - First 1 }
5866 $childResp = Invoke-WebRequest - Uri " https://ghcr.io/v2/$imagePath /manifests/$ ( $child.digest ) " - Method GET - Headers $manifestHeaders - ErrorAction Stop
59- $manifest = $childResp.Content | ConvertFrom-Json
67+ $manifest = ConvertFrom-RawJson $childResp.Content
6068 }
6169
6270 $version = $manifest.annotations .' org.opencontainers.image.version'
0 commit comments