{"record":{"id":"06e2f5e6fd8ec409","repo":"coleam00/Archon","slug":"failed-to-list-workflow-runs-err-message-06e2f5","errorCode":null,"errorMessage":"Failed to list workflow runs: ${err.message}","messagePattern":"Failed to list workflow runs: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/db/workflows.ts","lineNumber":1974,"sourceCode":"    );\n  }\n\n  const limit = options?.limit ?? 50;\n  values.push(limit);\n  const limitParam = `$${String(values.length)}`;\n\n  const whereStr = whereClauses.length > 0 ? `WHERE ${whereClauses.join(' AND ')}` : '';\n\n  try {\n    const result = await pool.query<WorkflowRun>(\n      `SELECT * FROM remote_agent_workflow_runs ${whereStr} ORDER BY started_at DESC LIMIT ${limitParam}`,\n      values\n    );\n    return result.rows.map(normalizeWorkflowRun);\n  } catch (error) {\n    const err = error as Error;\n    getLog().error({ err }, 'db.workflow_run_list_failed');\n    throw new Error(`Failed to list workflow runs: ${err.message}`);\n  }\n}\n\n/**\n * The open-work inbox (#2747): runs that ended with work on the table. Status-\n * derived v1 semantics — terminal AND failed AND no run has adopted or\n * superseded it (the NOT EXISTS closes the row behaviorally when a successor\n * claims it). Deletion is hard in this store, so \"not deleted\" holds by\n * construction. Paused/waiting/cancelled runs are excluded by design: they are\n * live or already judged.\n */\nexport async function findOpenWorkRuns(options?: {\n  codebaseId?: string;\n  limit?: number;\n}): Promise<WorkflowRun[]> {\n  const values: unknown[] = [];\n  let codebaseClause = '';\n  if (options?.codebaseId) {","sourceCodeStart":1956,"sourceCodeEnd":1992,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/db/workflows.ts#L1956-L1992","documentation":"Thrown by listWorkflowRuns when the filtered SELECT over `remote_agent_workflow_runs` fails. Driver/SQL errors are logged as `db.workflow_run_list_failed` and rethrown with this message. Empty results are normal; only an actual query failure throws.","triggerScenarios":"Calling listWorkflowRuns with filters when the DB is unreachable, a filter parameter type is rejected by the driver, or the dynamically built WHERE/ORDER SQL is invalid for the configured dialect.","commonSituations":"CLI `workflow list` during a database outage; passing an unsupported status/filter value that reaches the SQL layer; schema not migrated after switching engines; connection pool exhaustion.","solutions":["Inspect the `db.workflow_run_list_failed` log for the driver-level cause","Verify DB connectivity and schema/migration state","Check the filter object values (statuses, run ids, dates) are among the supported ones","Retry after transient connection failures"],"exampleFix":"// before\nconst runs = await listWorkflowRuns({ status: 'running' }); // throws on DB failure\n// after\ntry {\n  const runs = await listWorkflowRuns({ status: 'running' });\n} catch (e) {\n  logger.error({ err: e }, 'could not list workflow runs — is the database reachable?');\n  process.exitCode = 1;\n}","handlingStrategy":"try-catch","validationCode":"// validate filter values before querying\nconst allowed = new Set(['running','paused','failed','completed','cancelled']);\nif (filters?.status && !allowed.has(filters.status)) {\n  throw new Error(`unsupported status filter: ${filters.status}`);\n}","typeGuard":"function isRunListFilters(f: unknown): f is { status?: string; limit?: number } {\n  if (typeof f !== 'object' || f === null) return false;\n  const o = f as Record<string, unknown>;\n  return (o.status === undefined || typeof o.status === 'string') &&\n         (o.limit === undefined || typeof o.limit === 'number');\n}","tryCatchPattern":"try {\n  const runs = await listWorkflowRuns(filters);\n  render(runs);\n} catch (error) {\n  log.error({ err: error }, 'failed to list workflow runs — check database connectivity');\n  exit(1);\n}","preventionTips":["Verify DB connectivity before CLI commands that list runs","Keep schema migrations current after engine switches","Validate filters against the supported set at the command boundary","Monitor `db.workflow_run_list_failed` for recurring driver issues"],"tags":["database","workflow","query"],"backgroundTag":"database-query-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}