{"record":{"id":"4e31f2981609ddb4","repo":"coleam00/Archon","slug":"failed-to-create-the-workflow-run-error-as-err","errorCode":null,"errorMessage":"Failed to create the workflow run: ${(error as Error).message}\nNothing was started.","messagePattern":"Failed to create the workflow run: (.+?)\nNothing was started\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":2135,"sourceCode":"          metadata: {\n            // Declared inputs (#2554): `$INPUTS` is read off the row, so a pre-created\n            // row that omits them starts a run whose inputs silently disappeared.\n            ...(resolvedInputs && Object.keys(resolvedInputs).length > 0\n              ? { [SUBRUN_METADATA_KEYS.inputs]: { ...resolvedInputs } }\n              : {}),\n            ...(continuationDeclaration\n              ? { [CONTINUATION_METADATA_KEY]: { mode: continuationDeclaration.mode } }\n              : {}),\n          },\n          ...(detachedUserId ? { user_id: detachedUserId } : {}),\n          ...(continuationDeclaration\n            ? { adopted_from_run_id: continuationDeclaration.runId }\n            : {}),\n        });\n        detachedRunId = created.id;\n        launchedRunId = created.id;\n      } catch (error) {\n        throw new Error(\n          `Failed to create the workflow run: ${(error as Error).message}\\nNothing was started.`\n        );\n      }\n    }\n    // Pin a generated branch only when isolating AND the caller didn't pass\n    // --branch (an explicit --branch is already in argv). Without this, the child\n    // would generate its own timestamped branch and fork a second worktree.\n    // Never pin a branch for folder projects — they run in place with no worktree.\n    if (\n      wantsIsolation &&\n      !detachIsFolder &&\n      options.branchName === undefined &&\n      options.adoptRunId === undefined\n    ) {\n      pinnedBranch = `${workflowName}-${String(Date.now())}`;\n      extraArgs.push('--branch', pinnedBranch);\n    }\n    // Pin the conversation id only when generated (an explicit one is already in argv).","sourceCodeStart":2117,"sourceCodeEnd":2153,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L2117-L2153","documentation":"Thrown when `workflowDb.createWorkflowRun` fails while pre-creating the run row for a fresh detached launch. The CLI intentionally writes the row before forking the child so that 'Started' guarantees a queryable run; if the insert fails, nothing has been spawned yet, so the error states 'Nothing was started'. The underlying error message is embedded for diagnosis.","triggerScenarios":"Calling the workflow run command with detachment enabled when the run-row insert fails: database unreachable mid-command, NOT NULL/foreign-key violation (e.g. invalid conversation id or user id), schema mismatch from an older binary, or a constraint on adopted_from_run_id.","commonSituations":"Database went down between the conversation lookup and the insert; schema drift after an upgrade where the new metadata column is absent; adopting a run id that violates a foreign key.","solutions":["Read the embedded message to identify the underlying DB error.","Verify the database is still up and DATABASE_URL is correct.","Run schema initialization/upgrade so the workflow_runs table matches the binary's expectations.","If adopting/superseding, confirm the referenced run id exists in the database.","Retry the launch once the database is healthy."],"exampleFix":"// before\narchon workflow run my-flow --detach  # Failed to create the workflow run: relation \"workflow_runs\" does not exist\n// after\nbun run db:init   # or the project's schema-init command\narchon workflow run my-flow --detach","handlingStrategy":"try-catch","validationCode":"await db.execute(sql`select 1 from workflow_runs limit 1`); // schema + connectivity probe\nconst prior = adoptedRunId ? await workflowDb.getWorkflowRun(adoptedRunId) : null; // FK target exists","typeGuard":null,"tryCatchPattern":"try {\n  created = await workflowDb.createWorkflowRun({...});\n} catch (error) {\n  const msg = (error as Error).message;\n  console.error(`Run-row insert failed: ${msg}. Nothing was started; fix the DB and retry.`);\n  process.exit(1);\n}","preventionTips":["Run schema init/migrations after every upgrade before launching runs.","Confirm adopted/superseded run ids exist before passing them.","Monitor database uptime for long-running CLI sessions.","Keep binary and schema versions aligned."],"tags":["database","cli","insert-failure"],"backgroundTag":"workflow-run-create-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}