coleam00/Archon · error
Failed to find child workflow runs: ${err.message}
Error message
Failed to find child workflow runs: ${err.message} What it means
findChildRuns selects all workflow runs whose parent_run_id equals the given parent run id, oldest first. Driver/query errors are logged (db.workflow_run_find_children_failed) and rethrown wrapped in this message. An empty child list is a normal result, not an error.
Source
Thrown at packages/core/src/db/workflows.ts:756
}
/**
* Find every run spawned as a child of `parentRunId` (#2121 Phase 2), oldest
* first. Callers filter further by `metadata.parent_node_id` (a parent may have
* several `workflow:` nodes) or by status (the abandon cascade cancels
* non-terminal children).
*/
export async function findChildRuns(parentRunId: string): Promise<WorkflowRun[]> {
try {
const result = await pool.query<WorkflowRun>(
'SELECT * FROM remote_agent_workflow_runs WHERE parent_run_id = $1 ORDER BY started_at ASC',
[parentRunId]
);
return result.rows.map(row => normalizeWorkflowRun(row));
} catch (error) {
const err = error as Error;
getLog().error({ err, parentRunId }, 'db.workflow_run_find_children_failed');
throw new Error(`Failed to find child workflow runs: ${err.message}`);
}
}
/**
* Safety cap on the `parent_run_id` walk. The load-time and runtime cycle guards
* prevent creating a cyclic run tree, but a hand-edited DB must never hang the
* walk — deeper than the runtime depth cap (5) so a legitimately deep-but-bounded
* tree still resolves fully.
*/
const MAX_RUN_ANCESTRY_DEPTH = 32;
/**
* Walk `parent_run_id` from `runId` up to the root, returning ancestors nearest
* first (the immediate parent at index 0). Depth-capped and cycle-safe (a
* repeated id stops the walk). Used by the runtime cycle guard and to build the
* path-lock exclusion set for a shared-checkout sub-run.
*/
export async function getRunAncestry(runId: string): Promise<WorkflowRun[]> {View on GitHub (pinned to 0773b97458)
Solutions
- Read the wrapped err.message; 'column parent_run_id does not exist' means migrations are pending.
- Run the schema upgrade so parent_run_id exists, then retry.
- For transient connection errors, retry after the pool recovers — the query is read-only.
Example fix
// before
const children = await findChildRuns(parentRunId);
// after
let children: WorkflowRun[] = [];
try {
children = await findChildRuns(parentRunId);
} catch (err) {
getLog().error({ err, parentRunId }, 'children_walk_failed');
} Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the parent_run_id column exists (added in #2121 Phase 2)
const check = await pool.query(
`SELECT 1 FROM information_schema.columns WHERE table_name='workflow_runs' AND column_name='parent_run_id'`
);
if (check.rowCount === 0) throw new Error('schema upgrade required: parent_run_id missing'); Type guard
function isChildWalkError(err: unknown): err is Error {
return err instanceof Error && err.message.startsWith('Failed to find child workflow runs:');
} Try / catch
try {
const children = await findChildRuns(parentRunId);
} catch (err) {
if (/does not exist/.test(String(err))) throw new Error('apply schema upgrades first', { cause: err });
children = []; // only for acceptable degraded walks
} Prevention
- Keep binaries and schema in step: run the documented upgrade path when parent_run_id was added.
- An empty array is a valid answer — only catch for real DB errors.
- Cap retry attempts on transient connection errors.
- Alert on db.workflow_run_find_children_failed events.
When it happens
Trigger: Calling findChildRuns(parentRunId) during a DB outage, against a schema missing the parent_run_id column (pre-#2121 Phase 2 database), or when the driver throws a timeout/connection error on the SELECT.
Common situations: Older binary reading a database before parent_run_id was added, or vice versa (older DB opened by newer binary before upgrade steps); DB restart mid-walk; connection limit exceeded.
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
- Corrupt commands JSON for codebase ${id}: unable to parse st
- Codebase ${codebaseId} not found
- Conversation not found: ${conversationId}
- Failed to get workflow run status: ${err.message}
- Failed to get active workflow run: ${err.message}
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/b0387343a6daf384.
Report an issue: GitHub.