{"record":{"id":"2d29fa47bddb5c8c","repo":"tinyhumansai/openhuman","slug":"method-http-res-status-await-res-text","errorCode":null,"errorMessage":"${method}: HTTP ${res.status} ${await res.text()}","messagePattern":"(.+?): HTTP (.+?) (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/test-memory-email-ingest.mjs","lineNumber":53,"sourceCode":"import { resolve } from \"node:path\";\nimport process from \"node:process\";\n\nconst RPC_URL = process.env.RPC_URL || \"http://127.0.0.1:7810/rpc\";\nconst OWNER = process.env.OWNER || \"stevent95@gmail.com\";\nconst PROVIDER = process.env.PROVIDER || \"gmail\";\nconst FIXTURE =\n  process.argv[2] ||\n  resolve(\"tests/fixtures/memory/composio_gmail_inbox.json\");\n\nlet rpcId = 0;\nasync function rpc(method, params) {\n  rpcId += 1;\n  const res = await fetch(RPC_URL, {\n    method: \"POST\",\n    headers: { \"content-type\": \"application/json\" },\n    body: JSON.stringify({ jsonrpc: \"2.0\", id: rpcId, method, params }),\n  });\n  if (!res.ok) throw new Error(`${method}: HTTP ${res.status} ${await res.text()}`);\n  const body = await res.json();\n  if (body.error) {\n    throw new Error(`${method}: ${body.error.message || JSON.stringify(body.error)}`);\n  }\n  return body.result;\n}\n\nfunction parseEmailDate(raw) {\n  if (!raw) return Date.now();\n  if (typeof raw === \"number\") return raw < 1e12 ? raw * 1000 : raw;\n  const ms = Date.parse(raw);\n  return Number.isFinite(ms) ? ms : Date.now();\n}\n\nfunction splitAddresses(value) {\n  if (!value) return [];\n  if (Array.isArray(value)) return value.filter(Boolean);\n  return String(value)","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/scripts/test-memory-email-ingest.mjs#L35-L71","documentation":"The rpc() helper in this manual test driver POSTs a JSON-RPC 2.0 request to the core's /rpc endpoint (RPC_URL, default http://127.0.0.1:7810/rpc) and got a non-2xx HTTP status; it throws with the method name, status, and the raw response body.","triggerScenarios":"Transport-level rejection before JSON-RPC semantics apply: 401/403 when the bearer token (OPENHUMAN_CORE_TOKEN for a standalone core) is missing or stale; 404 when RPC_URL points at the wrong path or port; proxy or connection errors surfaced as status codes.","commonSituations":"Core restarted with a new token while the script kept the old env; RPC_URL pointing at a stale port from a previous run; standalone core started without the token the script assumes.","solutions":["Compare the rpc_url the script prints at startup with the port the core logged","Supply the current token: export OPENAI... no — export OPENHUMAN_CORE_TOKEN from {workspace}/core.token of the running core","Distinguish transport from method problems: curl the /health endpoint on the same base URL","Check the response body included in the error — it names what the server actually objected to"],"exampleFix":"# before\nnode scripts/test-memory-email-ingest.mjs fixture.json   # e.g. 'openhuman.memory_tree_ingest: HTTP 401 ...'\n\n# after\nexport RPC_URL='http://127.0.0.1:7810/rpc'\nexport OPENHUMAN_CORE_TOKEN=\"$(cat ~/.openhuman/users/<id>/workspace/core.token)\"\nnode scripts/test-memory-email-ingest.mjs fixture.json","handlingStrategy":"validation","validationCode":"const health = await fetch(new URL('../health', RPC_URL).toString());\nif (!health.ok) throw new Error(`core unhealthy (HTTP ${health.status}) — fix transport before RPC`);","typeGuard":null,"tryCatchPattern":"try { await rpc(method, params); }\ncatch (err) {\n  if (/^\\S+: HTTP \\d+/.test(err.message)) { console.error('transport-level failure:', err.message); process.exitCode = 1; }\n  else throw err;\n}","preventionTips":["health-check /health on the same base URL before driving /rpc","re-read core.token after every core restart","print RPC_URL in harness output for quick diffing against core logs"],"tags":["jsonrpc","http","testing","local-core"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}