{"record":{"id":"2c723f058e61d34e","repo":"stablyai/orca","slug":"commandlabel-args-join-failed-result","errorCode":null,"errorMessage":"${commandLabel} ${args.join(' ')} failed (${result.status}): ${result.stderr || result.stdout}","messagePattern":"(.+?) (.+?) failed \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/live-remote-freeze-rpc.mjs","lineNumber":95,"sourceCode":"    ...args,\n    ...(local ? [] : ['--environment', envName]),\n    '--json'\n  ]\n\n  function orcaJsonSync(args, opts = {}) {\n    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 = ''","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/live-remote-freeze-rpc.mjs#L77-L113","documentation":"The orca CLI child spawned successfully but exited with a non-zero status (result.status !== 0). The throw surfaces stderr if present, else stdout, so the underlying CLI error message is visible. This is the 'command ran and reported failure' mode — distinct from spawn failure (104) and from an RPC envelope that reports ok=false (106).","triggerScenarios":"The CLI rejects the arguments (unknown subcommand/flag), the target terminal/worktree does not exist, an auth/permission error, or the CLI hit an internal panic and exited non-zero. Common statuses include 1 (generic), 2 (usage), or a signal-encoded null status.","commonSituations":"Passing a terminal handle that was already closed, a worktree id that drifted, an orca version that renamed a subcommand, a timeout that surfaces as a non-zero exit, or rate/quota limits enforced by the CLI.","solutions":["Read the embedded stderr/stdout in the message — it is the CLI's own diagnostic and usually names the cause.","Reproduce by running the exact args.join(' ') shown in the message directly in a shell against the same target.","If the status is null the child was killed by a signal; raise opts.timeoutMs or check for OOM/SIGKILL.","For handle/worktree errors, re-list the resource and retry with a current id."],"exampleFix":"// before\nif (result.status !== 0) {\n  throw new Error(`${commandLabel} ${args.join(' ')} failed (${result.status}): ${result.stderr || result.stdout}`)\n}\n\n// after\nif (result.status !== 0) {\n  const detail = (result.stderr || result.stdout || '').slice(0, 500)\n  throw new Error(`${commandLabel} ${args.join(' ')} failed (${result.status}): ${detail}`)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isCliFailure = (r) => r && typeof r.status === 'number' && r.status !== 0","tryCatchPattern":"try {\n  return orcaJsonSync(args)\n} catch (e) {\n  const m = e.message.match(/failed \\((\\d+)\\):([\\s\\S]*)/)\n  if (m && recoverableStatus(Number(m[1]))) { /* re-list, retry once */ }\n  throw e\n}","preventionTips":["Surface the CLI's stderr verbatim in logs — it usually names the cause.","For handle-based commands, re-list the resource and retry once with fresh ids.","Distinguish signal-killed (status null) from real exit codes in retry logic."],"tags":["spawn","cli","exit-code","rpc"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}