{"record":{"id":"30e1b684d79971a0","repo":"stablyai/orca","slug":"codex-app-server-method-failed-response-erro","errorCode":null,"errorMessage":"codex app-server ${method} failed: ${response.error.message ?? 'unknown error'}","messagePattern":"codex app-server (.+?) failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/codex/codex-app-server-session.ts","lineNumber":258,"sourceCode":"      pending.set(id, { resolve, reject })\n      const payload: Record<string, unknown> = { method, id }\n      if (params !== undefined) {\n        payload.params = params\n      }\n      try {\n        sendLine(payload)\n      } catch (error) {\n        pending.delete(id)\n        reject(error instanceof Error ? error : new Error(String(error)))\n      }\n    })\n    if (response.error) {\n      if (isMethodNotFoundError(response.error)) {\n        throw new CodexAppServerUnsupportedError(\n          `codex app-server does not support ${method}: ${response.error.message ?? 'method not found'}`\n        )\n      }\n      throw new Error(\n        `codex app-server ${method} failed: ${response.error.message ?? 'unknown error'}`\n      )\n    }\n    return response.result\n  }\n\n  function buildEarlyExitError(): Error {\n    if (stderrIndicatesMissingAppServer(stderrTail)) {\n      return new CodexAppServerUnsupportedError(\n        `codex CLI does not support the app-server subcommand: ${stderrTail.trim().slice(0, 400)}`\n      )\n    }\n    return new Error(\n      `codex app-server exited before completing the session${stderrTail ? `: ${stderrTail.trim().slice(0, 400)}` : ''}`\n    )\n  }\n\n  try {","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/codex/codex-app-server-session.ts#L240-L276","documentation":"Thrown as a plain Error when a JSON-RPC response has an error that is NOT a method-not-found (code !== -32601 and message doesn't match 'method not found'). The codex app-server recognized the method but the call itself failed — an application-level error returned in response.error.message.","triggerScenarios":"thread/read failed because the rollout file is missing or corrupt ('no rollout found'); sqlite returned BUSY/LOCKED because another codex process owns the DB; config/batchWrite was rejected for a malformed edit; hooks/list failed on an unreadable hooks.json.","commonSituations":"A backfilled rollout was deleted after the audit was written; an active codex TUI holds sqlite; the hooks.state keyPath or value shape is wrong for this codex version; permissions on CODEX_HOME block the DB.","solutions":["Read response.error.message from the thrown string (after 'codex app-server <method> failed:') to classify.","For 'no rollout found', the rollout was deleted — healOneThread already maps this to 'missing'; let it record and continue.","For SQLITE_BUSY/LOCKED, abort the pass and retry on next startup when the other codex process releases the lock.","For config/batchWrite rejections, verify the keyPath (hooks.state.\") and mergeStrategy ('upsert'/'replace') match this codex version's writer.","Check CODEX_HOME permissions and disk space."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// For thread/read, pre-check the rollout file exists to avoid 'no rollout found':\nif (!existsSync(expectedRolloutPath)) {\n  // mark thread as missing without calling the RPC\n}","typeGuard":"function isAppServerRpcFailure(error: unknown, method: string): boolean {\n  return error instanceof Error && error.message.startsWith(`codex app-server ${method} failed:`)\n}","tryCatchPattern":"try {\n  await rpc.request(method, params)\n} catch (error) {\n  const msg = error instanceof Error ? error.message : String(error)\n  if (/no rollout found/i.test(msg)) { /* record missing, continue */ }\n  else if (/SQLITE_(?:BUSY|LOCKED)|database (?:is )?(?:busy|locked)/i.test(msg)) { /* abort batch, retry later */ }\n  else { /* genuine failure: record or rethrow by policy */ }\n}","preventionTips":["Parse response.error.message to classify missing vs locked vs genuine failure.","Abort and retry later on SQLITE_BUSY/LOCKED instead of burning the batch.","Verify config/batchWrite keyPath/mergeStrategy shapes against the codex version.","Ensure no concurrent codex process holds sqlite during heal."],"tags":["codex","app-server","json-rpc","rpc-error","sqlite"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}