coleam00/Archon · error

Failed to find adopting runs: ${err.message}

Error message

Failed to find adopting runs: ${err.message}

What it means

Thrown by the adopting-runs lookup when the reverse-direction query on `adopted_from_run_id` fails. The driver error is logged as `db.workflow_run_adopters_lookup_failed` (with runId) and rethrown with this message. Zero adopters is a normal empty result, not an error.

Source

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

    throw new Error(`Failed to list open workflow runs: ${err.message}`);
  }
}

/**
 * Runs that adopted or superseded `runId` (#2747) — the reverse direction of
 * `adopted_from_run_id`, same column, no second column. Newest first.
 */
export async function findAdoptingRuns(runId: string): Promise<WorkflowRun[]> {
  try {
    const result = await pool.query<WorkflowRun>(
      'SELECT * FROM remote_agent_workflow_runs WHERE adopted_from_run_id = $1 ORDER BY started_at DESC',
      [runId]
    );
    return result.rows.map(normalizeWorkflowRun);
  } catch (error) {
    const err = error as Error;
    getLog().error({ err, runId }, 'db.workflow_run_adopters_lookup_failed');
    throw new Error(`Failed to find adopting runs: ${err.message}`);
  }
}

/**
 * Update parent_conversation_id on a workflow run.
 * Non-critical — logs error but does not throw.
 */
export async function updateWorkflowRunParent(
  runId: string,
  parentConversationId: string
): Promise<void> {
  try {
    await pool.query(
      'UPDATE remote_agent_workflow_runs SET parent_conversation_id = $1 WHERE id = $2',
      [parentConversationId, runId]
    );
  } catch (error) {
    const err = error as Error;

View on GitHub (pinned to 0773b97458)

Solutions

  1. Read the `db.workflow_run_adopters_lookup_failed` log for the underlying driver error
  2. Verify database connectivity and retry — the lookup is read-only
  3. Validate the runId is a well-formed identifier before querying
  4. Check schema state if the runs table appears missing after an upgrade

Example fix

// before
const adopters = await findAdoptingRuns(runId); // throws on DB failure
// after
try {
  const adopters = await findAdoptingRuns(runId);
} catch (e) {
  logger.error({ runId, err: e }, 'could not look up adopting runs');
}
Defensive patterns

Strategy: try-catch

Validate before calling

// validate runId shape before the query
if (typeof runId !== 'string' || runId.length === 0) {
  throw new Error(`invalid runId for adopter lookup: ${String(runId)}`);
}

Type guard

function isValidRunId(v: unknown): v is string {
  return typeof v === 'string' && v.length > 0 && /^[A-Za-z0-9_-]+$/.test(v);
}

Try / catch

try {
  const adopters = await findAdoptingRuns(runId);
  if (adopters.length === 0) log.info({ runId }, 'no adopting runs');
} catch (error) {
  log.error({ runId, err: error }, 'adopter lookup failed — read-only, safe to retry');
  throw error;
}

Prevention

When it happens

Trigger: Calling the lookup with a runId when the DB is unreachable, the query fails at the driver, or the runs table is missing/unavailable due to schema drift.

Common situations: Tracing lineage of a run during a database outage; querying with a malformed runId that the driver rejects as a parameter; read-only replica rejecting the query.

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/f47ba8a8605b5785. Report an issue: GitHub.