tinyhumansai/openhuman · error · Error
RPC ${method} HTTP ${res.status}
Error message
RPC ${method} HTTP ${res.status} What it means
rpc() in scripts/debug/agent-prepare-context-audit.mjs parses the response body as JSON successfully, then checks res.ok; any non-2xx status throws 'RPC <method> HTTP <status>'. This is transport-level rejection at the HTTP layer — the server spoke valid JSON (often a JSON error object) but the status says the request itself was not accepted.
Source
Thrown at scripts/debug/agent-prepare-context-audit.mjs:281
}),
});
} catch (err) {
if (err?.name === "AbortError")
throw new Error(`RPC ${method} timed out after ${timeoutMs}ms`);
throw err;
} finally {
clearTimeout(timeout);
}
const bodyText = await res.text();
let body;
try {
body = JSON.parse(bodyText);
} catch {
throw new Error(
`RPC ${method} returned non-JSON HTTP ${res.status}: ${bodyText.slice(0, 200)}`,
);
}
if (!res.ok) throw new Error(`RPC ${method} HTTP ${res.status}`);
if (body.error)
throw new Error(
`RPC ${method} error: ${JSON.stringify(body.error).slice(0, 300)}`,
);
return body.result;
}
// ── Transcript reading ──────────────────────────────────────────────────────
async function walkJsonl(dir) {
const out = [];
async function walk(current) {
let entries;
try {
entries = await readdir(current, { withFileTypes: true });
} catch {
return;
}View on GitHub (pinned to a221052e0d)
Solutions
- On 401: re-fetch the token — cat the current workspace's core.token, or pass --spawn-core so the script generates and uses a matching token
- On 404: verify the URL includes /rpc and the core is the openhuman-core JSON-RPC server
- On 5xx: check the core's own logs (file-only core log stream) for the underlying failure and restart it
- Retry after the core is healthy — this is a state error, not a bad request shape
Example fix
# before $ OPENHUMAN_CORE_TOKEN=stale-token node scripts/debug/agent-prepare-context-audit.mjs Error: RPC core.ping HTTP 401 # after $ node scripts/debug/agent-prepare-context-audit.mjs --token "$(cat ~/.openhuman/users/<id>/workspace/core.token)"
Defensive patterns
Strategy: try-catch
Validate before calling
// Cheap auth probe before the expensive audit calls
const res = await fetch(coreUrl, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${token}` }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "core.ping", params: {} }) });
if (res.status === 401) throw new Error("bearer rejected (401) — re-read core.token from the running core's workspace or pass --token");
if (res.status === 404) throw new Error("route not found (404) — URL must include /rpc"); Try / catch
try {
return await rpc(coreUrl, token, method, params);
} catch (e) {
const m = /RPC \S+ HTTP (\d+)/.exec(e.message);
if (m) {
const status = Number(m[1]);
if (status === 401 || status === 403) throw new Error(`auth failed (${status}) — refresh the token from the live core`, { cause: e });
if (status >= 500) { await sleep(5_000); return rpc(coreUrl, token, method, params); } // core restarting
}
throw e;
} Prevention
- Tokens are per-launch: never reuse a core.token from a previous core run when attaching to a new one
- Probe with core.ping before kicking off a long audit — 401 there costs milliseconds instead of minutes
- 5xx right after --spawn-core usually means the core is still binding; wait and retry once
When it happens
Trigger: 401 when the bearer token is wrong/revoked (e.g. --token from a dead core's core.token while attaching to a newly spawned core with a fresh token); 403 for permission failures; 404 when the URL path is wrong (missing /rpc or a proxy route); 500 when the core's HTTP layer fails before JSON-RPC dispatch. Distinct from the non-JSON error (212), which fires when the body isn't even parseable.
Common situations: Mixing tokens between core runs — core.token is regenerated per launch, so a stale file yields 401; pointing at a core built with different feature gates so the route shape differs; reverse proxies returning 502 while the core restarts underneath the audit.
Related errors
- Core RPC HTTP ${response.status}: ${text || response.statusT
- RPC ${method} HTTP ${res.status}
- RPC ${method} HTTP ${res.status}
- Core RPC token unavailable in Tauri; local RPC auth cannot b
- [transport:cloud] HTTP ${response.status}: ${text || respons
AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16).
Data as JSON: /api/errors/3f85a3d2205d9b7f.
Report an issue: GitHub.