Skip to content

The agent that grows with you

fix(desktop-update): windows.ps1 keeps release holders in a plain array (PS 5.1 @() over List[object])

Teknium21ead66c5610
diff --git a/scripts/desktop-update/windows.ps1 b/scripts/desktop-update/windows.ps1
index e4508021715..c3d5353a433 100644
--- a/scripts/desktop-update/windows.ps1
+++ b/scripts/desktop-update/windows.ps1
@@ -708,7 +708,7 @@ function Write-Result([bool]$Ok, [int]$Code, [string]$Message, [bool]$ManualActi
warnings = @($script:Warnings)
release_holders = @($script:ReleaseHolders)
finished_at = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds()
- } | ConvertTo-Json -Compress
+ } | ConvertTo-Json -Compress -Depth 4
[System.IO.File]::WriteAllText($tmp, $obj, (New-Object System.Text.UTF8Encoding $false))
if ([System.IO.File]::Exists($ResultPath)) {
[System.IO.File]::Replace($tmp, $ResultPath, [NullString]::Value)
@@ -725,7 +725,9 @@ function Write-Result([bool]$Ok, [int]$Code, [string]$Message, [bool]$ManualActi
# Post-commit follow-ups (contract C3): each failed step after `hermes update`
# exited 0 becomes a warning, never a failed update.
$script:Warnings = New-Object System.Collections.Generic.List[string]
-$script:ReleaseHolders = New-Object System.Collections.Generic.List[object]
+# A plain array: Windows PowerShell 5.1's @() over a non-empty List[object] throws
+# "Argument types do not match".
+$script:ReleaseHolders = @()
$script:FollowupText = New-Object System.Collections.Generic.List[string]
$script:ManualFollowup = $false
$script:Committed = $false
@@ -1713,7 +1715,7 @@ try {
# hermes_cli/desktop_release_holders.py names each one on its own line; the
# relaunched Desktop offers to close exactly those and retry, never silently.
foreach ($m in [regex]::Matches(($res.Output -join "`n"), '(?m)^\s*Desktop app folder held by: (.+?) \(pid (\d+), (.+)\)\s*$')) {
- $script:ReleaseHolders.Add(@{ name = $m.Groups[1].Value; pid = [int]$m.Groups[2].Value; exe = $m.Groups[3].Value })
+ $script:ReleaseHolders += [pscustomobject]@{ name = $m.Groups[1].Value; pid = [int]$m.Groups[2].Value; exe = $m.Groups[3].Value }
}
if ($script:ReleaseHolders.Count -gt 0) {
$holderNames = (@($script:ReleaseHolders) | ForEach-Object { "$($_.name) (pid $($_.pid))" }) -join ', '
diff --git a/tests/scripts/desktop_update/test_desktop_update_windows_release_holders.py b/tests/scripts/desktop_update/test_desktop_update_windows_release_holders.py
index 83e3353ab0c..ad10447bf5e 100644
--- a/tests/scripts/desktop_update/test_desktop_update_windows_release_holders.py
+++ b/tests/scripts/desktop_update/test_desktop_update_windows_release_holders.py
@@ -52,7 +52,10 @@ def test_blocked_swap_result_names_the_holder_for_the_desktop(tmp_path: Path) ->
env={**os.environ, 'HERMES_HOME': str(home), 'HERMES_RUNTIME_DIR': str(tmp_path / 'empty-store'),
'PYTHONIOENCODING': 'utf-8'},
)
- result = json.loads((home / '.hermes-update-result.json').read_text(encoding='utf-8-sig'))
+ result_path = home / '.hermes-update-result.json'
+ log = home / 'logs' / 'desktop-update-handoff.log'
+ assert result_path.is_file(), (proc.stdout, log.read_text(encoding='utf-8', errors='replace') if log.is_file() else '')
+ result = json.loads(result_path.read_text(encoding='utf-8-sig'))
assert (result['ok'], result['manual']) == (True, True), (proc.stdout, result)
assert result['release_holders'] == [{'name': 'SogouCloud.exe', 'pid': 4242, 'exe': EXE}], result