fix(embedder_ui): show real errors when backend rpc.sock is unavailable #22

Merged
salmaelsoly merged 1 commit from development_ui_error_handling into development 2026-04-27 07:59:12 +00:00
Member

Summary

Fixes #20. Embedder dashboard panels now show clear inline error alerts when the backend rpc.sock is unavailable, instead of an opaque infinite "Loading..." with a cryptic JS console error.

Two coordinated changes in hero_embedder_ui templates:

  1. rpcCall validates response.ok and Content-Type before await response.json(). Non-OK + non-JSON responses (e.g. hero_router's text/plain 404 with body Socket 'rpc.sock' not found for 'hero_embedder') now throw Error("Backend unavailable (HTTP <status>): <body[:200]>") instead of SyntaxError: Unexpected token 'S'.
  2. Each panel poller renders a visible inline alert via a new shared renderPanelError(containerId, message) helper instead of console.error-and-forget. The namespace dropdown becomes a single disabled Namespaces unavailable: ... option. Recovery on next successful poll is automatic via the existing innerHTML/outerHTML rewrites; #loader-error is cleared on every refreshLoaderState entry.

Includes a small XSS-safe escapeHtml helper used by renderPanelError. The dropdown uses textContent and is therefore also safe.

Verified end-to-end in a headless browser against the live hero_router 404 path; browser console reported zero errors after the fix.

Test plan

  • cargo check --workspace --bins clean
  • Server Stats card shows alert when backend down
  • Namespace Stats card shows alert
  • Namespace dropdown disabled with Namespaces unavailable: ... option
  • Loader pane shows alert in #loader-error; form remains rendered
  • Logs tab shows alert
  • Browser console clean (no Unexpected token SyntaxError)
  • Verify recovery on next poll once hero_embedder_server can start (blocked locally by missing ONNX runtime / models — environmental, out of scope; recovery is structurally guaranteed by the existing success-path DOM rewrites)
## Summary Fixes #20. Embedder dashboard panels now show clear inline error alerts when the backend rpc.sock is unavailable, instead of an opaque infinite "Loading..." with a cryptic JS console error. Two coordinated changes in `hero_embedder_ui` templates: 1. `rpcCall` validates `response.ok` and `Content-Type` before `await response.json()`. Non-OK + non-JSON responses (e.g. `hero_router`'s `text/plain` 404 with body `Socket 'rpc.sock' not found for 'hero_embedder'`) now throw `Error("Backend unavailable (HTTP <status>): <body[:200]>")` instead of `SyntaxError: Unexpected token 'S'`. 2. Each panel poller renders a visible inline alert via a new shared `renderPanelError(containerId, message)` helper instead of `console.error`-and-forget. The namespace dropdown becomes a single disabled `Namespaces unavailable: ...` option. Recovery on next successful poll is automatic via the existing `innerHTML`/`outerHTML` rewrites; `#loader-error` is cleared on every `refreshLoaderState` entry. Includes a small XSS-safe `escapeHtml` helper used by `renderPanelError`. The dropdown uses `textContent` and is therefore also safe. Verified end-to-end in a headless browser against the live `hero_router` 404 path; browser console reported zero errors after the fix. ## Test plan - [x] `cargo check --workspace --bins` clean - [x] Server Stats card shows alert when backend down - [x] Namespace Stats card shows alert - [x] Namespace dropdown disabled with `Namespaces unavailable: ...` option - [x] Loader pane shows alert in `#loader-error`; form remains rendered - [x] Logs tab shows alert - [x] Browser console clean (no `Unexpected token` `SyntaxError`) - [ ] Verify recovery on next poll once `hero_embedder_server` can start (blocked locally by missing ONNX runtime / models — environmental, out of scope; recovery is structurally guaranteed by the existing success-path DOM rewrites)
fix(embedder_ui): show real errors when backend rpc.sock is unavailable
All checks were successful
Test / test (pull_request) Successful in 3m25s
39cf6cd9a2
salmaelsoly merged commit 25f5dd3bef into development 2026-04-27 07:59:12 +00:00
salmaelsoly deleted branch development_ui_error_handling 2026-04-27 07:59:17 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_embedder!22
No description provided.