[hero_lifecycle] shared admin RPC helpers hardcode bare /api/rpc; should be /api/{domain}/rpc #151
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_lib#151
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?
The shared admin/web RPC helpers —
window.rpc(parts/hero_scripts.html) and theapi_docs/jobs/logspanes'rpc-url— POST to bare/api/rpc. Butserve_domainsserves each domain at/api/{domain}/rpc(single domain =/api/main/rpc), so live RPC from any single-domain migrated admin returns-32000 Backend unavailable.Discovery/spec already use domain-scoped URLs (
DomainCache::resolveemits/api/{domain}/openrpc.json); only the RPC-call path is bare.Fix options: (a)
serve_domainsalso serves a bare/api/rpcalias for the single domain, or (b) the shared components use the resolved/api/{domain}/rpc. Affects all single-domain migrated admins (planner now, collab soon).Triage (verified on-box) — difficulty: M, breaking: no (but the obvious quick fix crashes)
Bug confirmed on-the-wire. Shared
window.rpc(parts/hero_scripts.html:37) + the api_docs/jobs/logs/terminal panes POST bare/api/rpc; the admin proxy forwards it verbatim to the peer's socket-local/api/rpc(openrpc_proxy/mod.rs:284). Butserve_domainsserves single-domain peers only at/api/{domain}/rpc(=/api/main/rpc), with no bare/api/rpc(manifest.rs:803-804), so the peer 404s → reshaped to-32000 Backend unavailable. Discovery/spec already work (domain-scoped openrpc.json). This is why hero_planner ships an interim domain-scopedrpc_url.Not breaking: the correct fix (a single-domain bare
/api/rpcalias) is purely additive on the wire — existing/api/{domain}/rpccallers untouched, machine SDKs already POST the domain-scoped path. No downstream build breaks.⚠️ Difficulty is M, not S — the obvious quick fix panics. Naively merging
oschema_server::build_routerintoserve_rpc_domains(the tempting ~5-line approach) double-registers/api/ping(already mounted byservice_root_router,rpc.rs:377) → axum panics on startup for every service (the documented die-loudly path). It also won't compile as written (noRpcStatein scope atserve_rpc_domains), and a per-domain variant duplicate-route-panics on multi-domain services (e.g. hero_proc, 4 domains).Correct approach: gate on
domains.len()==1at the launcher (serve_rpc_domains,manifest.rs:736); mount only/api/rpc+/api/openrpc.jsonfor the lone domain (NOT/api/ping/health/heroservice — those already exist); update the ~4 in-repo#[cfg(test)]assertions that hardcode bare/api/rpc(e.g.logs/mod.rs,core/tests.rs); then revert hero_planner's interim domain-scopedrpc_url(planner_admin/src/router.rs:62-66, per its own TODO).Option (b) alternative (no server alias): switch the shared templates to the resolved
/api/{domain}/rpc— but that's 7 edit sites + an asyncDomainCachehop into two currently-synchronous index handlers, for the same user-visible result. Option (a) is preferred.Consumers of the shared helper: hero_lib default shell, hero_planner_admin, hero_sync_gmail_admin (single-domain — also broken today). hero_proc_admin uses its own per-domain JS
rpc()and is unaffected. Option (a) fixes everyone server-side with zero per-consumer edits.Client half merged to
development(squash) — completing #151 alongside the already-landed server control plane.What landed (client side, in shared
hero_lifecycle):window.rpc(templates/parts/hero_scripts.html) now splits routing:ping/discover_domains→ bare/api/rpc(control plane), data methods →/api/{domain}/rpc(domain discovered once viadiscover_domains, cached; optional 3rddomainarg for multi-domain admins).rpc_urlis domain-scoped in both constructors —api_docs/router.rs::pane_handler(the actually-served path) andapi_docs/mod.rs::from_app— and the domain<select>now switchesrpc-urlalongsidespec-url.Verification:
hero_lifecyclebuilds; 51/51 lib tests pass serially (the context-test flakes are pre-existing parallel/disk races); live browser E2E on hero_planner — connection indicator green (ping → control plane →pong),window.rpc('workspace_list')→/api/main/rpc→ real data, api-docsrpc-urldomain-scoped, 0 RPC console errors.Coordination / follow-ups:
hero_scripts.html(#152 workaround), so it must re-sync that partial and drop its interimrpc_urloverride after bumping the hero_lib dep. Every other consumer that mounts the shared api-docs pane gets the fix transparently on rebuild.jobs/logs/terminalpanes still hardcode bare/api/rpc(same class of bug; no current consumer hits it — hero_proc uses its ownrpc-peerwiring) — worth a small follow-up.