Skip to content

fix(ui): harden config load errors#859

Merged
perber merged 2 commits into
mainfrom
fix/config-error-toast-safety
Apr 9, 2026
Merged

fix(ui): harden config load errors#859
perber merged 2 commits into
mainfrom
fix/config-error-toast-safety

Conversation

@perber
Copy link
Copy Markdown
Owner

@perber perber commented Apr 9, 2026

Show config load failures in the UI without exposing arbitrary non-JSON response bodies. Preserve structured API error messages such as the insecure HTTP guidance while falling back to generic status errors for unexpected responses.

Show config load failures in the UI without exposing arbitrary non-JSON response bodies. Preserve structured API error messages such as the insecure HTTP guidance while falling back to generic status errors for unexpected responses.
Copilot AI review requested due to automatic review settings April 9, 2026 10:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens how the UI surfaces /api/config load failures by displaying structured API error messages when available, while avoiding leaking arbitrary non-JSON response bodies to users.

Changes:

  • Adds error state to the config store and populates it when config loading fails.
  • Updates getConfig() to preferentially extract error/message from JSON error responses and otherwise fall back to a generic status-based error.
  • Displays config load failures via a toast and ensures the toast system is mounted during initial bootstrap.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ui/leafwiki-ui/src/stores/config.ts Tracks config load error state and exposes it via Zustand store.
ui/leafwiki-ui/src/lib/api/config.ts Implements safer error parsing for non-OK config responses.
ui/leafwiki-ui/src/App.tsx Shows config load errors via toast and mounts the toaster during bootstrap/refresh gating.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/leafwiki-ui/src/lib/api/config.ts
Comment thread ui/leafwiki-ui/src/App.tsx Outdated
Comment thread ui/leafwiki-ui/src/App.tsx Outdated
Use the fallback config error message when the API returns a non-JSON error body.

Keep the toaster mounted and allow the same config error to be shown again after a retry so startup failures remain visible.
@perber perber merged commit a2cb690 into main Apr 9, 2026
5 checks passed
@perber perber deleted the fix/config-error-toast-safety branch April 9, 2026 13:32
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.

2 participants