{"record":{"id":"eacaf92e4e542493","repo":"coleam00/Archon","slug":"failed-to-list-dashboard-runs-err-message","errorCode":null,"errorMessage":"Failed to list dashboard runs: ${err.message}","messagePattern":"Failed to list dashboard runs: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/db/workflows.ts","lineNumber":1914,"sourceCode":"    };\n    for (const row of countResult.rows) {\n      const n = Number(row.cnt);\n      counts.all += n;\n      if (row.status in counts) {\n        counts[row.status as keyof Omit<typeof counts, 'all'>] = n;\n      }\n    }\n\n    // Total for the current filter (with status applied)\n    const total = options?.status\n      ? (counts[options.status as keyof typeof counts] ?? 0)\n      : counts.all;\n\n    return { runs: listResult.rows.map(normalizeWorkflowRun), total, counts };\n  } catch (error) {\n    const err = error as Error;\n    getLog().error({ err }, 'list_dashboard_runs_failed');\n    throw new Error(`Failed to list dashboard runs: ${err.message}`);\n  }\n}\n\n/**\n * List workflow runs with optional filters.\n */\nexport async function listWorkflowRuns(options?: {\n  conversationId?: string;\n  status?: WorkflowRunStatus | WorkflowRunStatus[];\n  limit?: number;\n  codebaseId?: string;\n  /**\n   * Non-enforcing \"mine\" filter: when set, restrict to runs attributed to this\n   * user (`user_id = $N`). Absent → all runs (default visibility stays open).\n   */\n  userId?: string;\n}): Promise<WorkflowRun[]> {\n  const whereClauses: string[] = [];","sourceCodeStart":1896,"sourceCodeEnd":1932,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/db/workflows.ts#L1896-L1932","documentation":"Thrown by the dashboard runs listing function when its composite query (filtered run list plus total/count aggregates) fails. The driver error is logged as `list_dashboard_runs_failed` and rethrown wrapped with this message. The function builds status-count aggregates and pagination on `remote_agent_workflow_runs`, so filter/sort clauses can also surface SQL errors here.","triggerScenarios":"Calling listDashboardRuns with filter parameters while the DB is down, the generated WHERE/aggregate SQL is invalid for the configured engine, or the query times out under large datasets.","commonSituations":"Web dashboard load during a database outage or migration; a filter value producing invalid SQL for the dialect; slow queries timing out on very large run tables; read-replica lag or read-only replicas rejecting the query.","solutions":["Check the `list_dashboard_runs_failed` log entry for the underlying driver error","Verify database connectivity and that migrations are current for the deployed schema","Reduce page size / add indexes if timeouts occur on large run tables","Validate the filter arguments (statuses, dates) passed from the dashboard UI"],"exampleFix":"// before\nconst { runs, total } = await listDashboardRuns(filters); // throws on DB blip\n// after\nlet data;\ntry {\n  data = await listDashboardRuns(filters);\n} catch (e) {\n  data = { runs: [], total: 0, counts: emptyCounts }; // degraded dashboard\n  logger.error({ err: e }, 'dashboard runs unavailable');\n}","handlingStrategy":"fallback","validationCode":"// validate filters before the call\nconst validStatuses = new Set(['running','paused','failed','completed','cancelled']);\nif (filters.status && !validStatuses.has(filters.status)) throw new Error(`unsupported status filter: ${filters.status}`);","typeGuard":"function hasValidFilters(f: unknown): f is DashboardRunFilters {\n  return typeof f === 'object' && f !== null &&\n    (!('status' in f) || typeof (f as any).status === 'string' || (f as any).status == null);\n}","tryCatchPattern":"let dashboard;\ntry {\n  dashboard = await listDashboardRuns(filters);\n} catch (error) {\n  log.error({ err: error }, 'dashboard runs query failed; serving empty page');\n  dashboard = { runs: [], total: 0, counts: {} };\n}","preventionTips":["Bound page sizes and add indexes as run history grows","Keep filters within documented values; validate UI input","Check DB health endpoints before rendering dashboards","Watch `list_dashboard_runs_failed` log volume for degradation"],"tags":["database","dashboard","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"}