{"record":{"id":"3e48124dfba30173","repo":"rohitg00/agentmemory","slug":"init-method-get-path-res-status","errorCode":null,"errorMessage":"${init?.method || \"GET\"} ${path} -> ${res.status} ${res.statusText}","messagePattern":"\\$\\{init\\?\\.method \\|\\| \"GET\"\\} \\$\\{path\\} -> \\$\\{res\\.status\\} \\$\\{res\\.statusText\\}","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mcp/rest-proxy.ts","lineNumber":150,"sourceCode":"        `[@agentmemory/mcp] AGENTMEMORY_FORCE_PROXY set; skipping livez probe and trusting ${url}\\n`,\n      );\n    }\n    if (up) {\n      const handle: ProxyHandle = {\n        mode: \"proxy\",\n        baseUrl: url,\n        call: async (path, init) => {\n          const res = await fetch(`${url}${path}`, {\n            ...init,\n            headers: {\n              \"content-type\": \"application/json\",\n              ...authHeader(),\n              ...(init?.headers as Record<string, string> | undefined),\n            },\n            signal: AbortSignal.timeout(CALL_TIMEOUT_MS),\n          });\n          if (!res.ok) {\n            throw new Error(\n              `${init?.method || \"GET\"} ${path} -> ${res.status} ${res.statusText}`,\n            );\n          }\n          const text = await res.text();\n          return text ? JSON.parse(text) : null;\n        },\n      };\n      cached = handle;\n      cachedAt = Date.now();\n      return handle;\n    }\n    const local: LocalHandle = { mode: \"local\" };\n    cached = local;\n    cachedAt = Date.now();\n    return local;\n  })();\n  try {\n    return await probeInFlight;","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/mcp/rest-proxy.ts#L132-L168","documentation":"The MCP REST proxy resolves a handle by making an HTTP request to the agentmemory daemon. Any non-ok HTTP response (4xx/5xx) is converted into a thrown Error containing the method, path, HTTP status code, and status text. This is the standard failure mode when the daemon is unreachable, auth fails, or the endpoint returns an error.","triggerScenarios":"Calling any proxied tool while the daemon responds with e.g. 401 Unauthorized (bad secret), 404 (endpoint not registered / wrong AGENTMEMORY_URL path), 500 (handler threw), or 502/503 (daemon behind a proxy that cannot reach it).","commonSituations":"Daemon not running or listening on a different port, AGENTMEMORY_URL misconfigured, stale/missing auth token in authHeader(), a version mismatch where the client calls an endpoint the daemon doesn't expose.","solutions":["Read the HTTP status in the message: 401/403 -> fix the auth secret/token; 404 -> check AGENTMEMORY_URL and that the daemon version exposes the endpoint; 5xx -> check daemon logs.","Verify the daemon is running: curl AGENTMEMORY_URL/agentmemory/health.","Correct AGENTMEMORY_URL to point at the right host/port (default port 49134's REST surface).","Retry the call if the status is 5xx and the daemon was momentarily restarting."],"exampleFix":"// before\nconst res = await handle(\"memory_search\", { query }); // throws POST /agentmemory/search -> 401 Unauthorized\n// after\ntry {\n  const res = await handle(\"memory_search\", { query });\n} catch (e) {\n  if (/-> 40[13]/.test(e.message)) fixAuth();\n  else if (/-> 5\\d\\d/.test(e.message)) await retry(handle, [\"memory_search\", { query }]);\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":"async function daemonHealthy(url) {\n  try {\n    const r = await fetch(`${url}/agentmemory/health`, { signal: AbortSignal.timeout(2000) });\n    return r.ok;\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"const m = /^(\\w+) (\\S+) -> (\\d{3}) (.*)$/.exec(err.message);\nif (m) {\n  const [, method, path, status, statusText] = m;\n  if (status === \"401\" || status === \"403\") await refreshToken();\n  else if (status.startsWith(\"5\")) await retryWithBackoff();\n  else throw err; // 4xx: caller bug, don't retry\n}","preventionTips":["Health-check the daemon before issuing batches of proxied calls.","Keep AGENTMEMORY_URL and the auth secret sourced from one config shared by client and daemon.","Pin client and daemon to the same version so endpoints always exist.","Distinguish retryable (5xx) from non-retryable (4xx) statuses before retrying."],"tags":["http","network","rest-proxy"],"backgroundTag":"http-4xx-5xx-response","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}