{"record":{"id":"eecc8c7f4cf5fbf6","repo":"paperclipai/paperclip","slug":"could-not-resolve-worktree-selector-use-a-pa","errorCode":null,"errorMessage":"Could not resolve worktree \"${selector}\". Use a path, a listed worktree directory name, branch name, or \"current\".","messagePattern":"Could not resolve worktree \"(.+?)\"\\. Use a path, a listed worktree directory name, branch name, or \"current\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":2860,"sourceCode":"    if (!existsSync(configPath)) {\n      throw new Error(`Resolved worktree path ${directPath} does not contain .paperclip/config.json.`);\n    }\n    return {\n      rootPath: directPath,\n      configPath,\n      label: path.basename(directPath),\n      isCurrent: false,\n    };\n  }\n\n  const matched = choices.find((choice) =>\n    (allowCurrent || !choice.isCurrent)\n    && (choice.worktree === directPath\n      || path.basename(choice.worktree) === trimmed\n      || choice.branchLabel === trimmed),\n  );\n  if (!matched) {\n    throw new Error(\n      `Could not resolve worktree \"${selector}\". Use a path, a listed worktree directory name, branch name, or \"current\".`,\n    );\n  }\n  if (!matched.hasPaperclipConfig && !matched.isCurrent) {\n    throw new Error(`Resolved worktree \"${selector}\" does not look like a Paperclip worktree.`);\n  }\n  return resolveEndpointFromChoice(matched);\n}\n\nasync function promptForSourceEndpoint(excludeWorktreePath?: string): Promise<ResolvedWorktreeEndpoint> {\n  const excluded = excludeWorktreePath ? path.resolve(excludeWorktreePath) : null;\n  const currentEndpoint = resolveCurrentWorktreeEndpoint();\n  const choices = toMergeSourceChoices(process.cwd())\n    .filter((choice) => choice.hasPaperclipConfig || choice.isCurrent)\n    .filter((choice) => path.resolve(choice.worktree) !== excluded)\n    .map((choice) => ({\n      value: choice.isCurrent ? \"__current__\" : choice.worktree,\n      label: choice.branchLabel,","sourceCodeStart":2842,"sourceCodeEnd":2878,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L2842-L2878","documentation":"Thrown by resolveWorktreeEndpointFromSelector when the selector is non-empty, does NOT resolve to an existing path, and does not match any listed worktree by worktree dir, directory basename, or branch label. The resolver checks `git worktree list`-derived choices (toMergeSourceChoices) and falls back to this error when nothing matches. The message lists the accepted selector shapes.","triggerScenarios":"Typo in a branch name or directory name; referencing a worktree that was already removed/cleaned; selector is a path that doesn't exist; branch name from a different repository.","commonSituations":"Stale memory of a worktree name; cleaned worktree still referenced by an old command; cross-repo branch name confusion.","solutions":["List valid worktrees: `paperclipai worktree:list` and use one of the shown directories/branches.","Use 'current' to target the worktree you're inside.","Check for typos and that the path/branch actually exists in this repo.","If the worktree was removed, recreate it (`worktree:make`) before referencing it."],"exampleFix":"// before\npaperclipai worktree:merge-history --source feat-xyz   # no such worktree\n// after\npaperclipai worktree:list   # see valid names\npaperclipai worktree:merge-history --source feat-x","handlingStrategy":"validation","validationCode":"const choices = toMergeSourceChoices(process.cwd());\nconst ok = existsSync(path.resolve(selector))\n  || choices.some((c) => c.worktree === path.resolve(selector) || path.basename(c.worktree) === selector || c.branchLabel === selector);\nif (!ok) throw new Error(`Selector '${selector}' matches no worktree; see worktree:list`);","typeGuard":"function selectorResolvable(selector: string, choices: MergeSourceChoice[]): boolean {\n  const d = path.resolve(selector);\n  return existsSync(d) || choices.some((c) => c.worktree === d || path.basename(c.worktree) === selector || c.branchLabel === selector);\n}","tryCatchPattern":null,"preventionTips":["Run `worktree:list` and copy a valid directory/branch from its output.","Use 'current' when operating inside a worktree.","Double-check branch/path names for typos."],"tags":["worktree","validation","git","cli"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}