{"record":{"id":"7532348adbc64ff1","repo":"paperclipai/paperclip","slug":"cannot-rebuild-the-git-worktree-the-base-project","errorCode":null,"errorMessage":"Cannot rebuild the git worktree: the base project checkout path is empty.","messagePattern":"Cannot rebuild the git worktree: the base project checkout path is empty\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/workspace-runtime.ts","lineNumber":3397,"sourceCode":"    baseRefSha: readRecordedBaseRefSha(input.workspace.metadata),\n  };\n  const provisionCommand = asString(input.workspace.config?.provisionCommand, \"\").trim();\n\n  if (strategy !== \"git_worktree\") {\n    if (!await directoryExists(cwd)) {\n      return null;\n    }\n    return realized;\n  }\n  // Validate the base checkout before the git spawn. A missing or empty base\n  // path makes the \"git\" spawn fail with a raw \"spawn git ENOENT\" error. That\n  // error hides the real cause: the base project checkout is not on disk.\n  // Throw a clear cause first so a future failure names the missing checkout.\n  // Keep the persisted path exact. A directory name can start or end with a\n  // space, so a trim would change a valid checkout path.\n  const baseCwd = asString(input.base.baseCwd, \"\");\n  if (!baseCwd) {\n    throw new Error(\n      \"Cannot rebuild the git worktree: the base project checkout path is empty.\",\n    );\n  }\n  if (!await directoryExists(baseCwd)) {\n    throw new Error(\n      \"Cannot rebuild the git worktree: the base project checkout directory does not exist.\",\n    );\n  }\n  const repoRoot = await runGit([\"rev-parse\", \"--show-toplevel\"], baseCwd);\n  const recordedBaseRefSha = readRecordedBaseRefSha(input.workspace.metadata);\n  if (await directoryExists(cwd)) {\n    const reuseBaseRef = input.workspace.baseRef ?? input.base.repoRef ?? null;\n    const reuseWorktreePath = realized.worktreePath ?? cwd;\n    const repairWarnings: string[] = [];\n    if (await isGitCheckout(reuseWorktreePath)) {\n      const coherence = await ensureGitWorktreeBranchCoherent({\n        db: input.db ?? null,\n        repoRoot,","sourceCodeStart":3379,"sourceCodeEnd":3415,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/server/src/services/workspace-runtime.ts#L3379-L3415","documentation":"Worktree rebuild needs to create a git worktree off the base project checkout, but the recorded base checkout path exists yet is empty. The pre-spawn guard throws this clear cause instead of the confusing 'spawn git ENOENT'-style failure that would follow.","triggerScenarios":"Thrown at server/src/services/workspace-runtime.ts:3338 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Configure a base project checkout path for the workspace before rebuilding the worktree."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}