{"record":{"id":"50a77a5c43e371f2","repo":"stablyai/orca","slug":"commandlabel-args-join-ok-false-json","errorCode":null,"errorMessage":"${commandLabel} ${args.join(' ')} ok=false: ${JSON.stringify(parsed)}","messagePattern":"(.+?) (.+?) ok=false: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/live-remote-freeze-rpc.mjs","lineNumber":101,"sourceCode":"    const started = performance.now()\n    const result = spawnSync(cliInvocation.command, commandArgs(args, opts.local), {\n      encoding: 'utf8',\n      env: cliInvocation.env,\n      maxBuffer: MAX_ORCA_RPC_OUTPUT_BYTES,\n      timeout: opts.timeoutMs ?? 120_000\n    })\n    const elapsedMs = performance.now() - started\n    if (result.error) {\n      throw new Error(`${commandLabel} ${args.join(' ')} failed to start: ${String(result.error)}`)\n    }\n    if (result.status !== 0) {\n      throw new Error(\n        `${commandLabel} ${args.join(' ')} failed (${result.status}): ${result.stderr || result.stdout}`\n      )\n    }\n    const parsed = JSON.parse(result.stdout)\n    if (parsed.ok === false) {\n      throw new Error(`${commandLabel} ${args.join(' ')} ok=false: ${JSON.stringify(parsed)}`)\n    }\n    return { parsed, elapsedMs, result: parsed.result }\n  }\n\n  function orcaJsonAsync(args, opts = {}) {\n    const started = performance.now()\n    return new Promise((resolve, reject) => {\n      const child = spawn(cliInvocation.command, commandArgs(args, opts.local), {\n        env: cliInvocation.env,\n        stdio: ['ignore', 'pipe', 'pipe']\n      })\n      let stdout = ''\n      let stderr = ''\n      let outputBytes = 0\n      let settled = false\n      let timer\n      const fail = (error) => {\n        if (settled) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/live-remote-freeze-rpc.mjs#L83-L119","documentation":"The CLI exited zero and produced parseable JSON, but the RPC envelope has ok === false — the application-level failure channel. The full parsed object is serialized into the message so the remote's error field/code is visible. This is the deepest of the three orcaJsonSync failure modes (104 spawn, 105 exit code, 106 RPC ok=false).","triggerScenarios":"The orca RPC handler ran and returned a structured error: a requested resource (terminal/worktree/session) was not found, a state transition was invalid, an internal precondition failed, or the operation was rejected for safety. The CLI still exits 0 because it successfully delivered the response.","commonSituations":"Switching to a terminal that disconnected between list and switch, opening a flood terminal whose worktree vanished, a concurrent run mutating shared state, or a version where the RPC rejects an argument the older version accepted.","solutions":["Parse the JSON in the message — it contains result.error / result.code describing the RPC-level refusal.","Re-list the resource (e.g. 'terminal list') and retry with fresh handles; stale handles are the most common cause.","If the error is a precondition/state error, serialize competing runs so they do not mutate the same terminals concurrently.","Check remote-vs-local version skew (status.result.runtime.appVersion) since newer RPCs may reject older call shapes."],"exampleFix":"// before\nif (parsed.ok === false) {\n  throw new Error(`${commandLabel} ${args.join(' ')} ok=false: ${JSON.stringify(parsed)}`)\n}\n\n// after\nif (parsed.ok === false) {\n  const code = parsed.error?.code ?? 'UNKNOWN'\n  const msg = parsed.error?.message ?? JSON.stringify(parsed)\n  throw new Error(`${commandLabel} ${args.join(' ')} ok=false [${code}]: ${msg}`)\n}","handlingStrategy":"try-catch","validationCode":"if (parsed && parsed.ok === false) {\n  throw new Error(`RPC ${args.join(' ')} rejected [${parsed.error?.code}]: ${parsed.error?.message}`)\n}","typeGuard":"const isRpcError = (p) => p && p.ok === false","tryCatchPattern":"try {\n  return orcaJsonSync(args)\n} catch (e) {\n  if (/ok=false/.test(e.message) && /NOT_FOUND|STALE/.test(e.message)) {\n    return orcaJsonSync(args) // retry once after re-list\n  }\n  throw e\n}","preventionTips":["Treat RPC ok=false as recoverable for stale-resource codes by re-listing first.","Serialize competing repro runs so they don't mutate shared terminals concurrently.","Log remote vs local appVersion to spot version skew that changes RPC behavior."],"tags":["rpc","json","api-error","orchestration"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}