{"record":{"id":"cf331954d09d9d1d","repo":"paperclipai/paperclip","slug":"workspace-database-repair-command-failed-during","errorCode":null,"errorMessage":"Workspace database repair command failed during ${repairPhase}.","messagePattern":"Workspace database repair command failed during (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/routes/execution-workspaces.ts","lineNumber":776,"sourceCode":"              try {\n                const failedManifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as {\n                  phase?: unknown;\n                  state?: unknown;\n                };\n                seedFailurePhase = failedManifest.state === \"failed\" && typeof failedManifest.phase === \"string\"\n                  ? failedManifest.phase\n                  : null;\n              } catch {\n                // The outer repair phase remains exact when no seed phase was persisted.\n              }\n              await reportProgress({\n                metadata: { seedFailurePhase },\n                system: seedFailurePhase ? `Workspace seed failed during ${seedFailurePhase}.\\n` : null,\n              });\n              throw new Error(\n                repairCommandTimedOut\n                  ? `Workspace database repair command timed out during ${repairPhase}.`\n                  : `Workspace database repair command failed during ${repairPhase}.`,\n              );\n            }\n            if (!reseedObserved) {\n              await reportRepairPhase(\"target_backup\", \"succeeded\");\n              await reportRepairPhase(\"full_reseed\", \"started\");\n            }\n\n            const manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as Record<string, unknown>;\n            if (!isVerifiedWorktreeSeedManifest(manifest)) {\n              throw new Error(\"Workspace reseed returned without a verified terminal manifest.\");\n            }\n            const expectedInstanceId = resolveManagedWorkspaceInstanceId(workspaceCwd);\n            if (manifest.targetInstanceId !== expectedInstanceId) {\n              throw repairPreconditionError(\n                422,\n                \"seed_manifest_instance_mismatch\",\n                \"Verified seed manifest belongs to a different workspace instance.\",\n              );","sourceCodeStart":758,"sourceCodeEnd":794,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/server/src/routes/execution-workspaces.ts#L758-L794","documentation":"Thrown when the repair reseed child process exits with a non-zero code without a timeout — the CLI itself failed. The route reads <worktree>/.paperclip/seed-manifest.json to extract the persisted seedFailurePhase (manifest.state === \"failed\" with a string phase), reports it via operation progress, and throws this message naming the outer repair phase (target_backup or full_reseed). Full child stdout/stderr is captured in the workspace operation for diagnosis.","triggerScenarios":"POST repair where the spawned cli worktree reseed exits non-zero: source database corrupt or locked, target backup cannot be written (disk full), instance/company identity checks inside the CLI fail (PAPERCLIP_SEED_EXPECTED_COMPANY_ID mismatch), or the source config passed via --from-config is invalid. Any non-zero exit that is not the 20-minute timeout produces this error.","commonSituations":"Base .paperclip database locked by a running service during repair; PAPERCLIP_SEED_EXPECTED_COMPANY_ID env injected by the route not matching the source DB (company migrated/re-seeded); disk exhaustion during target backup; a worktree target whose .paperclip was left in a state the CLI refuses to overwrite without the expected flags.","solutions":["Read the workspace operation's captured stdout/stderr and the seedFailurePhase metadata — the CLI's own phase (e.g. source_open, target_backup) pinpoints the failure.","Open <worktree>/.paperclip/seed-manifest.json and check state/phase/attemptId for the CLI-side failure detail.","Fix the named phase: stop services holding locks on the base database, free disk space, or correct a company-id mismatch by re-registering the base.","Retry the repair action; the target is backed up and the worktree files are preserved, so re-runs are safe."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await repair(id);\n} catch (err) {\n  const op = await api.listWorkspaceOperations(id).then((ops) => ops.at(-1));\n  const phase = op?.metadata?.repairDiagnostics?.at(-1)?.phase ?? op?.metadata?.seedFailurePhase;\n  // route remediation by phase: source_open → fix/stop base DB locks; target_backup → free disk; etc.\n}","preventionTips":["Stop services and agents holding locks on the base .paperclip database before repairing.","Watch the workspace operation's captured stdout/stderr immediately after a failed repair — the CLI's own phase is recorded in metadata.seedFailurePhase.","Keep disk headroom for the --backup-target copy of the target database."],"tags":["workspace","repair","reseed","child-process","nonzero-exit","paperclip"],"backgroundTag":"nonzero-exit-code","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-21T17:58:32.592Z","contentChangedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}