From a81d60523d29c1e7bd2544d2d41aefc9c9e1965b Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Thu, 20 Aug 2026 10:01:37 +0800 Subject: [PATCH] fix(#48): stop the launcher turning child stderr into PowerShell errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The remaining red block came from go-admin's own "config init" line. That is the third informational stderr writer to surface this way, and the first two were only fixed by silencing them one at a time — the actual defect is in the launcher, not in any of the writers. `2>&1 |` makes PowerShell wrap every stderr line from a native command in an ErrorRecord, which renders as a NativeCommandError block and reads as a failed migration regardless of what the line says. Stringifying in the pipeline fixes the whole class, including SDK output this repo cannot change. Verified in Windows PowerShell from WSL: the bare pipeline produces the red block for a plain stderr line while the stringified one does not, and $LASTEXITCODE still reports the child's exit code (3) through the extra stage, so the migration failure check below is unaffected. Script parse-checked and run with -ValidateConfigOnly. Co-Authored-By: Claude Opus 5 --- scripts/start-server.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/start-server.ps1 b/scripts/start-server.ps1 index 3014089..904ebc9 100644 --- a/scripts/start-server.ps1 +++ b/scripts/start-server.ps1 @@ -228,7 +228,16 @@ try { $previousErrorActionPreference = $ErrorActionPreference try { $ErrorActionPreference = "Continue" + # Stringify before Tee-Object. With a bare `2>&1 |`, PowerShell wraps + # every line the child writes to stderr in an ErrorRecord, which prints + # as a red NativeCommandError block and reads as a failed migration -- + # even for ordinary informational output such as go-admin's + # "config init". Chasing individual stderr writers is whack-a-mole; this + # fixes the whole class. $LASTEXITCODE still reports the child's real + # exit code through the added pipeline stage, so failure detection below + # is unaffected. & go run . migrate -c config/settings.yml 2>&1 | + ForEach-Object { "$_" } | Tee-Object -FilePath $migrationLog $migrationExitCode = $LASTEXITCODE }