{"record":{"id":"d9f5a67fa3f41905","repo":"coleam00/Archon","slug":"cannot-dispatch-workflow-workflow-name-codeb","errorCode":null,"errorMessage":"Cannot dispatch workflow \"${workflow.name}\": codebase ${ctx.codebaseId} not found","messagePattern":"Cannot dispatch workflow \"(.+?)\": codebase (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/orchestrator/orchestrator.ts","lineNumber":402,"sourceCode":"  await db.updateConversation(workerConv.id, {\n    cwd: ctx.cwd,\n    codebase_id: ctx.codebaseId ?? null,\n    hidden: true,\n  });\n\n  // 3. Resolve isolation for this worker. Unless the workflow explicitly opts out of\n  // worktrees, each background workflow gets its own worktree — and isolation failure\n  // is then fatal (never fall back to running in a shared/parent worktree).\n  let workerCwd: string;\n  let codebaseBaseBranch: string | undefined;\n  // Per-child isolation resolver (#2121 slice 2, PR-A): a `workflow:` node with\n  // `isolation: 'worktree'` gets its own worktree per child. Built for git-repo\n  // codebases only; undefined otherwise → the engine fails such a node fast.\n  let resolveChildIsolation: ReturnType<typeof createChildWorktreeResolver> | undefined;\n  if (ctx.codebaseId) {\n    const codebase = await getCodebase(ctx.codebaseId);\n    if (!codebase) {\n      throw new Error(\n        `Cannot dispatch workflow \"${workflow.name}\": codebase ${ctx.codebaseId} not found`\n      );\n    }\n    codebaseBaseBranch = codebase.default_branch?.trim() || undefined;\n    if (codebase.kind !== 'folder') {\n      resolveChildIsolation = createChildWorktreeResolver({\n        codebaseId: codebase.id,\n        codebaseName: codebase.name,\n        canonicalRepoPath: codebase.default_cwd,\n        baseBranch: codebaseBaseBranch,\n        createdByPlatform: ctx.platform.getPlatformType(),\n        createdByUserId: ctx.userId,\n      });\n    }\n    if (workflow.worktree?.enabled === false) {\n      // Respect an explicit worktree opt-out: skip isolation and run in the parent's cwd.\n      getLog().info(\n        {","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/orchestrator/orchestrator.ts#L384-L420","documentation":"dispatchBackgroundWorkflowOwned validates that the ctx.codebaseId referenced by a dispatch actually exists before wiring worktree isolation and the base branch. If getCodebase returns null, it throws immediately so the workflow is not dispatched against an unknown codebase. This is a fail-fast guard for a dangling codebase reference.","triggerScenarios":"Calling dispatchBackgroundWorkflow with ctx.codebaseId set to an id that is not registered (deleted registration, typo, stale id from another install/database, or wrong database attached).","commonSituations":"A codebase was unregistered while a scheduler/cron still references its id; copying run configs between machines or databases; hand-edited workflow payloads; a stale UI session holding a deleted codebase id.","solutions":["Run the codebase list/registration command to see valid ids and register the missing codebase.","Correct the codebaseId in the dispatch context to a registered id.","Re-create the codebase registration if it was deleted and the id must stay stable.","Check you are pointed at the correct Archon database/install where the codebase exists."],"exampleFix":"// before\nawait dispatchBackgroundWorkflow({ ctx: { codebaseId: 'cb_123' }, ... });\n// after: verify registration first\nconst cb = await getCodebase('cb_123');\nif (!cb) throw new Error('Register codebase cb_123 before dispatching');\nawait dispatchBackgroundWorkflow({ ctx: { codebaseId: 'cb_123' }, ... });","handlingStrategy":"validation","validationCode":"const cb = await getCodebase(ctx.codebaseId);\nif (!cb) throw new Error(`codebase ${ctx.codebaseId} is not registered; register it before dispatch`);","typeGuard":null,"tryCatchPattern":"try {\n  await dispatchBackgroundWorkflow(req);\n} catch (e) {\n  if (e.message.includes('codebase') && e.message.includes('not found')) {\n    console.error('Register the codebase or fix codebaseId');\n  } else throw e;\n}","preventionTips":["Fetch codebase ids from the registry at dispatch time instead of hardcoding them.","Delete or update schedulers/automations when a codebase is unregistered.","Avoid copying codebase ids between installs or databases."],"tags":["orchestrator","codebase","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}