Skip to content

Commit aa7cf44

Browse files
authored
fix(install): Windows installer no longer reports failed doctor migration as complete (#120033)
* fix(install): Windows installer surfaces doctor migration failures Invoke-OpenClawCommand ignored the child exit code, so a failed 'openclaw doctor --non-interactive' still printed '[OK] Migration complete'. The wrapper now throws on nonzero exit and Run-Doctor reports the failure with the exact command to rerun instead of claiming success. * chore: re-fire CI * chore: re-fire CI against fixed main baseline
1 parent 5621979 commit aa7cf44

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎scripts/install.ps1‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,10 @@ function Invoke-OpenClawCommand {
882882
}
883883

884884
& $commandPath @Arguments
885+
$exitCode = $LASTEXITCODE
886+
if ($exitCode -ne 0) {
887+
throw "openclaw $($Arguments -join ' ') failed with exit code $exitCode."
888+
}
885889
}
886890

887891
function Invoke-InteractiveOpenClawCommand {
@@ -1608,10 +1612,10 @@ function Run-Doctor {
16081612
Write-Host "[*] Running doctor to migrate settings..." -ForegroundColor Yellow
16091613
try {
16101614
Invoke-OpenClawCommand doctor --non-interactive
1615+
Write-Host "[OK] Migration complete" -ForegroundColor Green
16111616
} catch {
1612-
# Ignore errors from doctor
1617+
Write-Host "[!] Migration failed; continuing. Run: openclaw doctor --non-interactive" -ForegroundColor Yellow
16131618
}
1614-
Write-Host "[OK] Migration complete" -ForegroundColor Green
16151619
}
16161620

16171621
function Test-GatewayServiceLoaded {

‎test/scripts/install-ps1.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,36 @@ describe("install.ps1 failure handling", () => {
104104
}
105105
const scriptWithoutEntryPoint = source.replace(ENTRYPOINT_RE, "");
106106
const cases = [
107+
{
108+
name: "openclaw-native-command-exit",
109+
source: [
110+
scriptWithoutEntryPoint,
111+
"",
112+
"function Get-OpenClawCommandPath { return (Get-Process -Id $PID).Path }",
113+
"$caught = $false",
114+
"try {",
115+
" Invoke-OpenClawCommand -NoLogo -NoProfile -Command 'exit 17'",
116+
"} catch {",
117+
" if ($_.Exception.Message -notmatch 'failed with exit code 17') { throw }",
118+
" $caught = $true",
119+
"}",
120+
"if (-not $caught) { throw 'nonzero native exit was accepted' }",
121+
"",
122+
].join("\n"),
123+
},
124+
{
125+
name: "doctor-failure-output",
126+
source: [
127+
scriptWithoutEntryPoint,
128+
"",
129+
"function Invoke-OpenClawCommand { throw 'doctor failed' }",
130+
"$output = @(Run-Doctor *>&1 | ForEach-Object { $_.ToString() })",
131+
'$text = $output -join "`n"',
132+
"if ($text -match 'Migration complete') { throw 'doctor failure reported success' }",
133+
"if ($text -notmatch 'Migration failed') { throw \"missing warning: $text\" }",
134+
"",
135+
].join("\n"),
136+
},
107137
{
108138
name: "node-versions",
109139
source: [

0 commit comments

Comments
 (0)