{"record":{"id":"04c3dffae6691fd6","repo":"coleam00/Archon","slug":"cannot-resume-database-lookup-failed-error-co","errorCode":null,"errorMessage":"Cannot resume: Database lookup failed.\nError: ${codebaseLookupError.message}\nHint: Check your database connection before using --resume.","messagePattern":"Cannot resume: Database lookup failed\\.\nError: (.+?)\nHint: Check your database connection before using --resume\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":2363,"sourceCode":"      } else {\n        console.log(\n          `Adopting run ${adoptedRun.id} — folder projects run in place; adoption carries provenance and $ADOPTED_RUN_DIR access only.`\n        );\n      }\n    } else {\n      const superseded = await resolveSupersededRun(adoptedFromRunId);\n      console.log(`Superseding run ${superseded.id} — fresh lane, provenance recorded.`);\n    }\n  }\n\n  // Handle --resume: locate the prior failed run, reuse its worktree, and hand\n  // the resumed-run handle to executeWorkflow below via opts. The executor no\n  // longer performs implicit resume detection on its own.\n  let resumable: WorkflowRun | null = null;\n  if (options.resume) {\n    if (!codebase) {\n      if (codebaseLookupError) {\n        throw new Error(\n          'Cannot resume: Database lookup failed.\\n' +\n            `Error: ${codebaseLookupError.message}\\n` +\n            'Hint: Check your database connection before using --resume.'\n        );\n      }\n      if (codebaseRegistrationError) {\n        throw buildRegistrationFailureError('resume', codebaseRegistrationError);\n      }\n      throw new Error(\n        'Cannot resume: Not in a git repository.\\n' +\n          'Either run from a git repo or use /clone first.'\n      );\n    }\n\n    if (resumeLookupError) {\n      throw buildResumeLookupFailureError(resumeLookupError);\n    }\n    // Resolved before discovery (top of this function), because the graph this run","sourceCodeStart":2345,"sourceCodeEnd":2381,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L2345-L2381","documentation":"When --resume is requested but the codebase (project) could not be resolved because the database lookup itself failed, the CLI aborts with this error. Resume must find the prior run and its worktree via the database, so a broken DB connection makes resume impossible; the wrapped message carries the lookup error and the hint tells the user to fix the connection first.","triggerScenarios":"Running `archon workflow run <flow> --resume` where resolveRunCodebase set lookupError — the database query for the project failed because the DB is down, DATABASE_URL is wrong, or the schema is missing.","commonSituations":"Postgres container stopped between runs; DATABASE_URL changed after switching from local to remote DB; first run after cloning without db init.","solutions":["Restore the database connection (start the server, fix DATABASE_URL).","Verify connectivity with a direct client before retrying --resume.","Run schema init/migrations if tables are missing.","Retry `--resume` once the lookup succeeds.","If the database is unrecoverable, start a fresh run instead of resuming."],"exampleFix":"// before\narchon workflow run my-flow --resume  # Cannot resume: Database lookup failed. Error: connect ECONNREFUSED\n// after\ndocker compose up -d db && archon workflow run my-flow --resume","handlingStrategy":"validation","validationCode":"// before --resume, probe the database\nif (!process.env.DATABASE_URL) throw new Error('DATABASE_URL not set; --resume needs the DB.');\nawait db.execute(sql`select 1`);","typeGuard":null,"tryCatchPattern":"try {\n  await runWorkflow({ resume: true });\n} catch (error) {\n  const msg = (error as Error).message;\n  if (msg.startsWith('Cannot resume: Database lookup failed.')) {\n    console.error('Fix the DB connection (see embedded Error:) then retry --resume.');\n  } else throw error;\n}","preventionTips":["Verify DB connectivity before any resume operation.","Keep the database service running across dev sessions.","Run migrations after upgrades so lookups do not fail on missing tables."],"tags":["database","resume","cli","connectivity"],"backgroundTag":"missing-database-url","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}