{"record":{"id":"7c7948332fb7c360","repo":"paperclipai/paperclip","slug":"managed-worktree-repair-requires-an-embedded-postg","errorCode":null,"errorMessage":"Managed worktree repair requires an embedded PostgreSQL target.","messagePattern":"Managed worktree repair requires an embedded PostgreSQL target\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":4252,"sourceCode":"      );\n    }\n    p.outro(\n      pc.green(\n        `Imported ${applied.insertedProjects} projects (${applied.insertedProjectWorkspaces} workspaces), ${applied.insertedIssues} issues, ${applied.insertedComments} comments, ${applied.insertedDocuments} documents (${applied.insertedDocumentRevisions} revisions, ${applied.mergedDocuments} merged), and ${applied.insertedAttachments} attachments into ${company.issuePrefix}.`,\n      ),\n    );\n  } finally {\n    await targetHandle.stop();\n    await sourceHandle.stop();\n  }\n}\n\nasync function backupWorktreeReseedTarget(input: {\n  targetConfig: PaperclipConfig;\n  targetPaths: WorktreeLocalPaths;\n}): Promise<string> {\n  if (input.targetConfig.database.mode !== \"embedded-postgres\") {\n    throw new Error(\"Managed worktree repair requires an embedded PostgreSQL target.\");\n  }\n  const targetHandle = await ensureEmbeddedPostgres(\n    input.targetConfig.database.embeddedPostgresDataDir,\n    input.targetConfig.database.embeddedPostgresPort,\n  );\n  try {\n    const adminConnectionString = `postgres://paperclip:paperclip@127.0.0.1:${targetHandle.port}/postgres`;\n    await ensurePostgresDatabase(adminConnectionString, \"paperclip\");\n    const result = await runDatabaseBackup({\n      connectionString: `postgres://paperclip:paperclip@127.0.0.1:${targetHandle.port}/paperclip`,\n      backupDir: path.resolve(input.targetPaths.backupDir, \"repair\"),\n      retention: { dailyDays: 30, weeklyWeeks: 12, monthlyMonths: 12 },\n      filenamePrefix: `${input.targetPaths.instanceId}-pre-repair`,\n      backupEngine: \"auto\",\n      includeMigrationJournal: true,\n    });\n    return formatDatabaseBackupResult(result);\n  } finally {","sourceCodeStart":4234,"sourceCodeEnd":4270,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/cli/src/commands/worktree.ts#L4234-L4270","documentation":"backupWorktreeReseedTarget(), used by the worktree repair flow (worktreeRepairCommand), only knows how to back up an embedded PostgreSQL target: it starts the embedded cluster via ensureEmbeddedPostgres and runs runDatabaseBackup against it. If the worktree config's database.mode is anything other than 'embedded-postgres' (e.g. an external Postgres via URL), it refuses rather than guess how to back up an external database.","triggerScenarios":"Running `paperclipai worktree repair` on a worktree whose paperclip config sets database.mode to a non-embedded value (external Postgres connection).","commonSituations":"Worktree originally created against a shared/external Postgres; config edited to point at an external database; repair attempted on instances managed outside the embedded-postgres lifecycle.","solutions":["Reconfigure the worktree to database.mode 'embedded-postgres' before running repair","Or skip managed repair and back up / repair the external database with your own tooling (pg_dump, WAL archiving)","Or recreate the worktree so it uses the embedded database the repair path expects"],"exampleFix":"# before (paperclip.config.json)\n\"database\": { \"mode\": \"postgres\", \"url\": \"postgres://host:5432/paperclip\" }\n\n# after\n\"database\": {\n  \"mode\": \"embedded-postgres\",\n  \"embeddedPostgresDataDir\": \"./data/pglite-or-pgdata\",\n  \"embeddedPostgresPort\": 5433\n}","handlingStrategy":"validation","validationCode":"const config = readWorktreeConfig(configPath);\nif (config.database.mode !== 'embedded-postgres') {\n  throw new Error('Managed repair supports embedded-postgres targets only; back up the external DB yourself.');\n}\nawait worktreeRepairCommand(opts);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize worktrees on embedded-postgres if you rely on managed repair","Maintain your own backup strategy (pg_dump/WAL) for external-database worktrees"],"tags":["worktree","repair","postgres","config","backup"],"backgroundTag":"unsupported-database-mode","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}