Skip to content

Surface the real error when magic-mode flashing fails - #101

Merged
eliasbakken merged 1 commit into
mainfrom
fix/magic-error-surfacing
Aug 10, 2026
Merged

Surface the real error when magic-mode flashing fails#101
eliasbakken merged 1 commit into
mainfrom
fix/magic-error-surfacing

Conversation

@eliasbakken

Copy link
Copy Markdown
Contributor

Summary

Two bugs combined to make every magic-mode failure look like a generic "unknown error":

  1. flash-from-url ran the download/decompress pipeline as (wget | pv | xz) 2> /tmp/recore-flash-progress - redirecting the whole pipeline's stderr into the progress file swallowed wget's and xz's real error output along with it.
  2. Even what little did get logged never reached the UI - goMagic() only ever set state.Error to a generic "An error was encountered during magic. Check log for details" message, which regular users can't act on.

Fixed by capturing each pipeline stage's stderr separately (per-command redirect, not for the whole subshell) and using PIPESTATUS to report whichever stage actually failed, and by having goMagic() surface that specific message to the UI instead of the generic one.

Also dropped wget's -q flag, which turned out to suppress its error output along with its progress noise.

Testing

  • make test-bats - un-skipped and fixed the existing (pending) test for this issue; added a stub_stderr test helper since the real fix needed to distinguish stdout (test's canned fake data) from stderr (where wget's real diagnostics go).
  • go test ./... - no regressions.
  • Live-tested on real hardware via the actual /api/start_magic call:
    • 404 (real file missing) → "Download failed: ... ERROR 404: Not Found."
    • unresolvable host (no internet/DNS) → "Download failed: wget: unable to resolve host address '...'"

Closes #59

Two bugs combined to make every magic-mode failure look like a
generic "unknown error":

1. flash-from-url ran the download/decompress pipeline as
   (wget | pv | xz) 2> /tmp/recore-flash-progress - redirecting the
   whole pipeline's stderr into the progress file swallowed wget's and
   xz's real error output along with it, leaving nothing useful
   anywhere.

2. Even what little did get logged never reached the UI: goMagic()
   only ever set state.Error to the generic "An error was encountered
   during magic. Check log for details" - regular users can't get to
   that log anyway.

Fixed by capturing each pipeline stage's stderr separately (redirected
per-command, not for the whole subshell) and using PIPESTATUS to
report whichever stage actually failed, and by having goMagic() surface
that specific message to the UI instead of the generic one.

Also dropped wget's -q flag, which turned out to suppress its error
output along with its progress noise - needed stdout quiet (that's the
image data) but not stderr.

Live-tested on real hardware via the actual /api/start_magic call:
- 404 (real file missing) -> "Download failed: ... ERROR 404: Not Found."
- unresolvable host (no internet/DNS) -> "Download failed: wget: unable
  to resolve host address '...'"

Closes #59
@eliasbakken
eliasbakken merged commit c6d8253 into main Aug 10, 2026
2 checks passed
@eliasbakken
eliasbakken deleted the fix/magic-error-surfacing branch August 10, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An unknown error sometimes happens when running magic mode.

1 participant