Skip to content

The agent that grows with you

fix(desktop-update): any failure after the banner keeps a killed update failed

teknium17f7e1ab402d5
diff --git a/scripts/desktop-update/windows.ps1 b/scripts/desktop-update/windows.ps1
index 771a3b4038d..2bda29767dc 100644
--- a/scripts/desktop-update/windows.ps1
+++ b/scripts/desktop-update/windows.ps1
@@ -1255,10 +1255,14 @@ function Invoke-HermesStep([string]$Exe, [string[]]$HermesArgs, [string]$Tag) {
# Invoke-HermesStep terminated the tree (#96205). The install is done; failing
# would keep the old Desktop and a legacy install would re-run the whole update.
# Surface success so the hand-off verifies, restores the gateways and relaunches.
-# Only 124 is remapped, and never after "✗ Update not complete": that verdict
-# (hermes_cli/update_receipt.py) is printed after the banner and supersedes it.
+# Only 124 is remapped, and never when anything after the banner reports a
+# failure: the restart/verify phase prints "✗ Update not complete", "Update
+# incomplete — …", "✗ <unit> failed to come back after restart" or
+# "verification incomplete" there. \u2717 (✗) stays an escape: Windows
+# PowerShell reads this BOM-less script as ANSI, never as UTF-8.
function Resolve-HermesUpdateOutcome($StepResult) {
- if ($StepResult.Code -eq 124 -and $StepResult.Output -match 'Update complete!' -and $StepResult.Output -notmatch 'Update not complete') {
+ $banner = if ($StepResult.Output) { $StepResult.Output.LastIndexOf('Update complete!') } else { -1 }
+ if ($StepResult.Code -eq 124 -and $banner -ge 0 -and $StepResult.Output.Substring($banner) -notmatch 'incomplete|not complete|\u2717') {
Write-HandoffLog "update completed before the idle watchdog killed its finalizing step (exit 124); treating it as success, not retrying (#96205)"
$StepResult.Code = 0
}
diff --git a/tests/scripts/desktop_update/test_desktop_update_windows_python_handoff.py b/tests/scripts/desktop_update/test_desktop_update_windows_python_handoff.py
index da25f416138..3bcef6043da 100644
--- a/tests/scripts/desktop_update/test_desktop_update_windows_python_handoff.py
+++ b/tests/scripts/desktop_update/test_desktop_update_windows_python_handoff.py
@@ -74,13 +74,15 @@ def test_pm_handoff_reports_update_and_gateway_results(
@pytest.mark.platforms('windows')
@pytest.mark.parametrize(('output', 'code'), [
('✓ Update complete! (v1.0.0)', 0),
- ('✓ Update complete! (v1.0.0)|✗ Update not complete: 1 gateway(s) still running the old code', 124),
+ ('✓ Update complete! (v1.0.0)| ✗ hermes-gateway failed to come back after restart.', 124),
+ ('✓ Update complete! (v1.0.0)|Update incomplete — some units were not restarted', 124),
('Cloning into the checkout...', 124),
])
def test_update_killed_by_idle_watchdog_after_completing_is_a_success(
tmp_path: Path, output: str, code: int,
) -> None:
- """#96205: a finished update parked silently in its restart phase is still finished."""
+ """#96205: a finished update parked silently in its restart phase is still finished,
+ unless anything after its banner already reported a failure."""
install = tmp_path / 'checkout'
publish_fixture_launcher(install, CLI)
(install / 'hermes_cli/desktop_update_verify.py').write_text('pass\n')