bug: context selection has no effect — all contexts return same data #37
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_biz#37
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?
Summary
Navigating to
/c/{contextname}/always displays the same data regardless of which context name is used in the URL. The context string is never transmitted to the OSIS server as a namespace selector.Root Cause
The bug is two layers deep in
hero_rpc'sOsisClient(native/non-WASM path):Layer 1 — Wrong URL path
OsisClient::newbuilds the endpoint as{base_url}/rpc/{context}(e.g.http://localhost:9988/rpc/owh). The OSIS unified server only registers the exact route/rpc— a request to/rpc/owhis a 404. The context name in the path is structurally ignored.Layer 2 — Missing
X-Hero-ContextheaderThe OSIS server selects context via the
X-Hero-ContextHTTP header (accepts an integer index or a string name like"owh").OsisClient::rpc_callsends onlyContent-Type: application/json— no context header. When the header is absent, the server defaults tocontext_names[0](first registered context, typically"root"or"default").Result: Every call from
Store::business_for(context),Store::projects_for(context), andStore::identity_for(context)hits the same OSIS context regardless of the URL.Trace
Fix Location
hero_rpc—crates/openrpc_http_client_lib/src/lib.rs,rpc_call(native path):X-Hero-Context: {context_name}to the outgoing request headers.{base_url}/rpc(drop the context path segment).Affected Code in hero_biz
crates/hero_biz_ui/src/services/mod.rs:74—business_for()crates/hero_biz_ui/src/services/mod.rs:97—projects_for()crates/hero_biz_ui/src/services/mod.rs:120—identity_for()/c/:context/*routesExpected Behaviour
/c/owh/companiesand/c/incubaid/companiesreturn data from their respective OSIS contexts.Implementation Specification: Fix Context Selection and URL Construction (Issue #37)
Investigation confirms that context selection is failing because the underlying
hero_rpclibrary incorrectly constructs URLs and fails to forward the requiredX-Hero-Contextheader over Unix sockets.1. hero_rpc Patches
1.1 Transport Layer (
crates/openrpc/src/transport.rs)Update
OpenRpcTransportto support HTTP headers over Unix Domain Sockets (UDS).http_post_unix: Update signature to acceptextra_headersand add them to thehyper::Requestbuilder.post_raw_json_with_headers: Passextra_headerstohttp_post_unixforUnixSockettransport.1.2 Client Library (
crates/openrpc_http_client_lib/src/lib.rs)Correct the
OsisClientendpoint for the unified OSIS server.OsisClient::new(Native): Change endpoint from{base_url}/hero_osis_{domain}/rpcto{base_url}/rpc.endpoint(WASM): Change endpoint to{base_url}/rpc.2. hero_biz Integration
Apply a local patch to
Cargo.tomlto use the modifiedhero_rpc.3. Acceptance Criteria
OpenRpcTransportcorrectly forwards theX-Hero-Contextheader over Unix sockets.OsisClienttargets the unified/rpcendpoint.hero_bizsuccessfully loads data filtered by the selected context.Final Implementation Summary
The fix for context selection has been implemented and verified.
1. hero_rpc Patches
OpenRpcTransportto support HTTP headers over Unix Domain Sockets. TheX-Hero-Contextheader is now correctly transmitted using HTTP-over-UDS.OsisClientto use the unified/rpcendpoint for all OSIS services.test_unix_socket_headerstocrates/openrpc/tests/openrpc_transport.rswhich confirms that headers are received by the server over UDS.2. hero_biz Integration
Cargo.tomlwith a[patch]section pointing to the local modifiedhero_rpc.hero_bizbuilds and passes its workspace tests.3. Verification
hero_rpcintegration tests: 11 passedhero_bizworkspace check: PassedRoot cause identified — dependency lock issue
After tracing the full call chain, the bug is a stale dependency lock in
hero_osis, not a code problem in hero_biz itself.What hero_biz actually does (correct)
The Store correctly threads context through the stack:
Where the bug lives
hero_bizdepends onhero_osis_sdk(git, branch=development).hero_osis_sdkin turn depends onhero_rpc_client(also git, branch=development), but itsCargo.lockpins it to commit0a08b9c6.That commit constructs the endpoint as:
This puts context in the URL path (
http://localhost:9988/rpc/threefold) instead of in theX-Hero-Contextheader, and does not include the domain in the path. The OSIS server ignores the path segment and returns default-context data every time.The fix already exists in hero_rpc as commit
ed6e7eb3c0(feat(OsisClient): per-domain URL routing + X-Hero-Context header), which constructs:What needs to happen
Step 1 — in
hero_osisrepo: UpdateCargo.lockso thathero_rpc_clientresolves to commited6e7eb3c0or later. Runcargo update -p hero_rpc_clientin the hero_osis workspace, then commit the updated lock file.Step 2 — in
hero_biz: Runcargo update -p hero_osis_sdkto pick up the updated hero_osis commit and commit the updatedCargo.lock.No code changes are needed in hero_biz itself — the context plumbing is already correct.
superseded by #40