coleam00/Archon · error · Error

Failed to get workflow run: ${err.message}

Error message

Failed to get workflow run: ${err.message}

What it means

Thrown by `archon workflow get` when the workflow-run lookup fails for a non-empty reason (DB error, store failure). In --json mode the CLI never throws; it emits a parseable {ok:false} JSON line with exit code 1 so a consuming agent always gets JSON.

Source

Thrown at packages/cli/src/commands/workflow.ts:3675

  json?: boolean,
  verbose?: boolean,
  cwd?: string,
  rawEvents?: boolean
): Promise<number> {
  let run: WorkflowRun | null;
  try {
    const resolvedId = await resolveRunIdArg(runId, cwd);
    run = await workflowDb.getWorkflowRun(resolvedId);
  } catch (error) {
    const err = error as Error;
    getLog().error({ err, runId }, 'cli.workflow_get_failed');
    // In --json mode never throw — emit one parseable {ok:false} line (same
    // contract as the write commands) so a parsing agent always gets JSON.
    if (json) {
      await writeJsonLine({ ok: false, runId, error: err.message });
      return 1;
    }
    throw new Error(`Failed to get workflow run: ${err.message}`);
  }

  if (!run) {
    // Not-found exits non-zero so `get <id> && ...` and CI checks see the
    // failure (the JSON envelope already carries ok:false for parsers).
    if (json) {
      await writeJsonLine({ ok: false, runId, error: 'not_found' });
    } else {
      console.log(`Workflow run not found: ${runId}`);
    }
    return 1;
  }

  // getWorkflowRun returns the base WorkflowRun (no current_step_name) — derive
  // per-node detail from the event log, and only when verbose is requested.
  let events: WorkflowEventRow[] | undefined;
  let eventsFailed = false;
  if (verbose) {

View on GitHub (pinned to 0773b97458)

Solutions

  1. Check the database connection/config (ARCHON_DSN or local workspace DB) and that the workspace is initialized with `archon setup`.
  2. Re-run with --json to get the underlying err.message in the {ok:false} line instead of a thrown error.
  3. Inspect CLI logs for the 'cli.workflow_get_failed'-style event to see the original err object.
  4. If the DB is corrupted, restore from backup or re-create the workspace database.

Example fix

// before
throw new Error(`Failed to get workflow run: ${err.message}`);
// after (consume as caller)
try { await cmd(); } catch (e) { console.error(e.message); process.exit(1); }
Defensive patterns

Strategy: try-catch

Validate before calling

const idOk = /^[0-9a-f-]{36}$/i.test(runId); if (!idOk) throw new Error('pass a full run id or use --json');

Type guard

function isErrWithMessage(e: unknown): e is Error { return e instanceof Error && typeof e.message === 'string'; }

Try / catch

try { await getRun(id, { json: true }); } catch (e) { /* with --json this shouldn't throw; parse the {ok:false} line instead */ }

Prevention

When it happens

Trigger: Running `archon workflow get <id>` when the workflow database is unavailable, corrupted, or the store throws during getWorkflowRun; any non-Error-unwrappable failure surfaced as err.message.

Common situations: SQLite/Postgres connection failure, database file locked or moved, running the CLI outside an initialized Archon workspace where the DB schema is missing.

Related errors


AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01). Data as JSON: /api/errors/bc8d139f9aa58e57. Report an issue: GitHub.