{"record":{"id":"c2a1294c95577db0","repo":"coleam00/Archon","slug":"failed-to-load-codebase-codebaseid-for-workfl","errorCode":null,"errorMessage":"Failed to load codebase '${codebaseId}' for workflow run '${runId}': ${err.message}\nCannot safely discover workflows from the run worktree because project workflow files may be missing.\nFix the codebase lookup problem, then retry.","messagePattern":"Failed to load codebase '(.+?)' for workflow run '(.+?)': (.+?)\nCannot safely discover workflows from the run worktree because project workflow files may be missing\\.\nFix the codebase lookup problem, then retry\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":4197,"sourceCode":"    const codebase = await codebaseDb.getCodebase(codebaseId);\n    if (!codebase) {\n      throw new Error(\n        `Workflow run '${runId}' references codebase '${codebaseId}', but that codebase no longer exists.\\n` +\n          'Cannot safely discover workflows from the run worktree because project workflow files may be missing.\\n' +\n          'Re-register the project or restore the codebase row, then retry.'\n      );\n    }\n    return codebase.default_cwd;\n  } catch (error) {\n    const err = error as Error;\n    if (err.message.includes('references codebase')) {\n      throw err;\n    }\n    getLog().error(\n      { err, errorType: err.constructor.name, runId, codebaseId },\n      `cli.workflow_${action}_codebase_lookup_failed`\n    );\n    throw new Error(\n      `Failed to load codebase '${codebaseId}' for workflow run '${runId}': ${err.message}\\n` +\n        'Cannot safely discover workflows from the run worktree because project workflow files may be missing.\\n' +\n        'Fix the codebase lookup problem, then retry.'\n    );\n  }\n}\n\n/**\n * Resume a failed workflow run by ID.\n *\n * Re-executes the workflow with --resume semantics: `workflowRunCommand` locates\n * the prior failed run via findResumableRun and hands it to the executor, which\n * skips already-completed nodes (the executor no longer auto-detects on its own).\n *\n * `runId` may be the short id printed by `workflow runs` (see resolveRunIdArg).\n */\nexport async function workflowResumeCommand(\n  runId: string,","sourceCodeStart":4179,"sourceCodeEnd":4215,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L4179-L4215","documentation":"Wrapper for unexpected failures during the codebase lookup step of run actions (resume/approve/reject/respond). Unlike the missing-row case, here getCodebase itself threw; the original error is logged with the runId/codebaseId and rethrown with action-specific context plus the same guidance about workflow discovery.","triggerScenarios":"`workflow resume/approve/reject/respond` when codebaseDb.getCodebase throws — DB connection failure, locked SQLite file, driver-level error — while resolving the run's project directory.","commonSituations":"Database offline or misconfigured DSN, SQLite file permissions/lock contention from another process, corrupted DB page, transient Postgres restart.","solutions":["Check logs for 'cli.workflow_<action>_codebase_lookup_failed' to see the original error class and message.","Restore database connectivity (start Postgres / unlock SQLite / fix DSN) and retry the action.","Verify DB file permissions and that no other process holds an exclusive lock.","If corruption is suspected, restore the database from backup on a scratch copy and verify."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (!fs.existsSync(workspaceDbPath) || !fs.accessSync(workspaceDbPath, fs.constants.R_OK)) throw new Error('database unavailable before run action');","typeGuard":null,"tryCatchPattern":"try { await respond(runId, body); } catch (e) { if (String(e.message).includes('Failed to load codebase')) { await sleep(backoff); return respond(runId, body); } throw e; }","preventionTips":["Retry transient DB failures with backoff before surfacing to the operator.","Monitor the 'cli.workflow_<action>_codebase_lookup_failed' log event for root-cause error classes.","Verify DSN/file-lock health after Postgres restarts or SQLite backup jobs."],"tags":["cli","database","workflow"],"backgroundTag":"codebase-lookup-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}