Browser app: API Docs tab fails ("Unexpected end of JSON input") + health-check report #11
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_browser#11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while testing the Browser app (iframed in hero_os from
/hero_browser/ui/).1. API Docs tab fails to load
Steps
Expected: tab shows the OpenRPC method documentation (grouped accordion).
Actual: shows
Root cause
crates/hero_browser_ui/templates/index.html:180does:With
base_path = /hero_browser/ui(set fromX-Forwarded-Prefixby hero_router), this fetches/hero_browser/ui/openrpc.json. hero_router routes/<svc>/ui/...toui.sock, buthero_browser_uihas no/openrpc.jsonroute — the spec is served byhero_browser_serveronrpc.sock. The UI returns404with an empty body, whichawait resp.json()then chokes on.Verified via curl:
GET /hero_browser/ui/openrpc.json→404, empty bodyGET /hero_browser/ui/rpc/openrpc.json→200 OK, full spec (sibling shortcut: hero_router rewrites/<svc>/ui/rpc[/…]→rpc.sock, seehero_router/src/server/routes.rs:1062-1106)GET /hero_browser/rpc/openrpc.json→200 OK(direct rpc prefix, also fine)Suggested fix (one line)
Same bug, second instance
crates/hero_browser_ui/templates/base.html:26— the navbar OpenRPC button:Opens a 404 page in a new tab for the same reason. Should become
{{ base_path }}/rpc/openrpc.json.2. Health check fails
Reported alongside the above
Need to reproduce: where is the failure visible — the connection-status dot in the navbar, a console error, a popover row showing
❌, or somewhere else? A DevTools Network/Console screenshot would pinpoint it. Possibly related to Item 1 (the only failing endpoint observed in this dashboard so far).Implementation Spec for Issue #11
Objective
Fix the broken
/openrpc.jsonURL in two places inhero_browser_uiso it routes through hero_router'sui/rpc[/...]sibling shortcut, which forwards torpc.sockwhere the spec is actually served.Requirements
Files to Modify
crates/hero_browser_ui/templates/index.html— change thefetch()URL in the API Docs tab loader.crates/hero_browser_ui/templates/base.html— change the OpenRPC<a href="">in the navbar.Implementation Plan
Step 1: Patch both template URLs
Files:
crates/hero_browser_ui/templates/index.html,crates/hero_browser_ui/templates/base.htmlindex.html:180:fetch("{{ base_path }}/openrpc.json")->fetch("{{ base_path }}/rpc/openrpc.json")base.html:26:href="{{ base_path }}/openrpc.json"->href="{{ base_path }}/rpc/openrpc.json"Dependencies: none
Step 2: Build and runtime-verify
cargo build -p hero_browser_ui(release)hero_browser_uiaction viahero_procso the new templates take effectcurlboth URLs through hero_router to confirm 200 + JSON body:GET /hero_browser/ui/rpc/openrpc.jsonGET /hero_browser/rpc/openrpc.json(control)Dependencies: Step 1
Acceptance Criteria
cargo build -p hero_browser_uisucceeds.Notes
/<svc>/ui/rpc[/...]->rpc.sockrewrite (hero_router/src/server/routes.rs:1062-1106). For standaloneui.sock(no router in front),/openrpc.jsonwas never reachable from the UI either way; that is out of scope for this fix.hero_rpc_derive::openrpc_proxy!macro tohero_browser_ui(the pattern used byhero_proc_ui). That adds two git dependencies and a router merge; not pursued here because the one-line per-template fix is sufficient via the existing router shortcut.Implementation Summary (revised)
Three issues fixed on
development_apidocs_fix, all incrates/hero_browser_ui/templates/:A. API Docs tab (Item 1 in the report)
index.html:180-- fetch URL changed:Same fix in
base.html:26for the navbar OpenRPC button.B. Health-check failure (Item 2 in the report)
Root cause (different from A; surfaced via the request log shared on the issue):
hero_router 308-redirects
/hero_browser/ui/->/hero_browser/ui(strips trailing slash). With the document URL ending at.../ui(no slash), browser-relative URL resolution drops the last segment, sofetch("health")fromconnection-status.js:167resolves to/hero_browser/health-- a non-route on hero_router -> 404 -> connection-status widget shows backend down.The same trap silently affected
fetch("rpc")indashboard.js:7; that one happened to work only because hero_router also exposes the rpc proxy at the bare service-root/<svc>/rpc. Fragile, not load-bearing on intent.Fix -- one line in
base.html<head>:All relative URLs the page issues (current
health/rpc, plus anything any future JS adds) now resolve under the UI prefix regardless of trailing slash. No JS edits, no new dependencies.C. Bonus:
_servergroup label in the API Docs accordionindex.html:185-189was usingm.name.indexOf(".")and falling back to a literal group named"_server"for any method without a dot. Since most hero_browser methods arebrowser_*,page_*,element_*etc. (no dots), they all bucketed into one ugly group called_server.Now groups become
browser,page,element,js,viewport,network,console,cookies,dialog,accessibility,key,file,rpc-- one bucket per method family.Diff stat
No Rust changes, no new dependencies.
Build & runtime verification
cargo build -p hero_browser_ui --release-- ok in ~7.5s (incremental).rpc.sock+ui.sockrebound.~/hero/build/cargo/releasecleaned post-build per local convention.Curl-verified through
hero_router:GET /hero_browser/ui/rpc/openrpc.json200valid OpenRPC spec (was 404 at/hero_browser/ui/openrpc.json)GET /hero_browser/ui/health200{"service":"hero_browser_ui","status":"ok","version":"0.1.0"}POST /hero_browser/ui/rpc {rpc.health}200{"service":"hero_browser","status":"ok","version":"0.1.0"}/hero_browser/ui/<head><base href="/hero_browser/ui/" />GET /hero_browser/health(the URL that was failing)Acceptance criteria
Branch
development_apidocs_fix(no push, no PR per the workflow this skill follows).