coleam00/Archon · error

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

Error message

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

What it means

getWorkflowRunStatus queries workflow_runs for the status of a single run id. Any database error (connection loss, permissions, malformed query, server crash) is logged with the event db.workflow_run_get_status_failed and rethrown wrapped in this message. The wrap exists to tell the caller which DB operation failed while preserving the underlying pg error text via err.message.

Source

Thrown at packages/core/src/db/workflows.ts:522

    return result.rows.map(normalizeWorkflowRun);
  } catch (error) {
    const err = error as Error;
    getLog().error({ err }, 'db.workflow_run_find_by_prefix_failed');
    throw new Error(`Failed to find workflow runs by id prefix: ${err.message}`);
  }
}

export async function getWorkflowRunStatus(id: string): Promise<string | null> {
  try {
    const result = await pool.query<{ status: string }>(
      'SELECT status FROM remote_agent_workflow_runs WHERE id = $1',
      [id]
    );
    return result.rows[0]?.status ?? null;
  } catch (error) {
    const err = error as Error;
    getLog().error({ err }, 'db.workflow_run_get_status_failed');
    throw new Error(`Failed to get workflow run status: ${err.message}`);
  }
}

export async function getActiveWorkflowRun(conversationId: string): Promise<WorkflowRun | null> {
  try {
    const result = await pool.query<WorkflowRun>(
      `SELECT * FROM remote_agent_workflow_runs
       WHERE (conversation_id = $1 OR parent_conversation_id = $2) AND status = 'running'
       ORDER BY started_at DESC LIMIT 1`,
      [conversationId, conversationId]
    );
    const row = result.rows[0];
    return row ? normalizeWorkflowRun(row) : null;
  } catch (error) {
    const err = error as Error;
    getLog().error({ err }, 'db.workflow_run_get_active_failed');
    throw new Error(`Failed to get active workflow run: ${err.message}`);
  }

View on GitHub (pinned to 0773b97458)

Solutions

  1. Check the inner err.message in the log event db.workflow_run_get_status_failed to identify the real driver error.
  2. Verify DATABASE_URL and that the database server is reachable (psql/nc to host:port).
  3. Run the project's schema setup/migrations so the workflow_runs table exists.
  4. Check the DB user has SELECT on workflow_runs.
  5. If the error is transient (connection reset), retry the call after the pool recovers.

Example fix

// before
const status = await getWorkflowRunStatus(runId);
// after
let status: string | null;
try {
  status = await getWorkflowRunStatus(runId);
} catch (err) {
  status = null; // surface degraded status instead of crashing the request
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Optionally confirm DB reachability before querying
const ping = await pool.query('SELECT 1');
if (!ping) throw new Error('database unavailable');

Type guard

function isDbWrappedError(err: unknown): err is Error & { message: string } {
  return err instanceof Error && err.message.startsWith('Failed to get workflow run status:');
}

Try / catch

try {
  const status = await getWorkflowRunStatus(runId);
} catch (err) {
  // inner err.message carries the driver-level cause
  getLog().error({ err }, 'run_status_lookup_failed');
  status = null;
}

Prevention

When it happens

Trigger: Calling getWorkflowRunStatus(runId) when the Postgres/SQLite pool is unreachable, when the workflow_runs table is missing (fresh DB without migrations), when credentials lack SELECT on workflow_runs, or when the underlying driver throws a transient network error mid-query.

Common situations: Postgres container not running or restarted; DATABASE_URL pointing at the wrong host/port; running an older binary against a DB where the workflow_runs table was added by a later migration; TLS/connection-pool exhaustion under load.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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