Skip to content

Fix: report Books, Now Playing and Backup failures in the widget's own words - #10

Merged
SandObserver merged 1 commit into
mainfrom
fix/widget-data-vouched-messages
Aug 9, 2026
Merged

SandObserver merged 1 commit into
mainfrom
fix/widget-data-vouched-messages

Conversation

@SandObserver

Copy link
Copy Markdown
Owner

Summary

  • Replace every user-facing throw new Error(...) in ui/widgets/{books,nowplaying,backup}/data.js with ctx.fail(message, { kind }). A plain Error is sanitised to a generic message by api/src/api-error.js, so 29 written-for-the-user sentences were being discarded.
  • Thread ctx through the Backup helper chain (dupLogin, dupRefresh, dupGetToken, dupFetch, kopiaFetch, duplicatiJobs, kopiaSources, slots) in place of the bare fetchJSON, since none of them could reach ctx.fail before.
  • Replace the two empty catch {} blocks in backup/data.js with ctx.log.warn. Behaviour is unchanged — one unreachable instance still leaves its own slots null rather than failing the widget — but the reason is no longer discarded.
  • Stop interpolating Navidrome's own error text into a vouched message; a vouched message may carry only words this repo chose.
  • Add a guard in api/test/widget-error.test.js asserting no widget reports a user-facing failure with a plain Error. connections is exempt, with the reason recorded: it catches its own throws and surfaces them as a per-service error field inside a successful result, which the convention allows.
  • Strip ctx.log.* calls before the existing raw-caught-message scan, so logging a caught error is not mistaken for sending it to the browser.

Testing
All green. Added 1 guard test and updated backup-data.test.js, whose fake ctx now provides fail, KIND and log like the real one. Mutation-checked by reverting one call to a plain throw.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.
  • CHANGELOG.md updated under Unreleased if the change is user-visible.

…n words

These three reported failures with a plain Error, which api-error.js replaces
with "Something went wrong." on the way out. So "Audiobookshelf URL and API key
required" and "Authentication failed, check password" never reached anyone.

They use ctx.fail now, with a kind on each. The Backup helpers took a bare
fetchJSON and had no way to reach ctx, so they take ctx itself.

Backup swallowed two upstream failures with an empty catch. One unreachable
instance still leaves its own slots null rather than failing the whole widget,
but the reason is logged now instead of discarded.

Navidrome no longer interpolates the upstream error text into the message it
vouches for; a vouched message may carry only words this repo chose.
@SandObserver SandObserver added bug Something isn't working javascript Pull requests that update javascript code labels Aug 9, 2026
@SandObserver
SandObserver merged commit 5c0db75 into main Aug 9, 2026
4 checks passed
@SandObserver
SandObserver deleted the fix/widget-data-vouched-messages branch August 9, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant