{"record":{"id":"effc1e0d1e05f561","repo":"paperclipai/paperclip","slug":"invalid-scope-rawvalue-expected-a-comma-sepa","errorCode":null,"errorMessage":"Invalid scope \"${rawValue}\". Expected a comma-separated list of: ${WORKTREE_MERGE_SCOPES.join(\", \")}.","messagePattern":"Invalid scope \"(.+?)\"\\. Expected a comma-separated list of: (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree-merge-history-lib.ts","lineNumber":332,"sourceCode":"    if (createdDelta !== 0) return createdDelta;\n    return left.id.localeCompare(right.id);\n  });\n}\n\nexport function parseWorktreeMergeScopes(rawValue: string | undefined): WorktreeMergeScope[] {\n  if (!rawValue || rawValue.trim().length === 0) {\n    return [\"issues\", \"comments\"];\n  }\n\n  const parsed = rawValue\n    .split(\",\")\n    .map((value) => value.trim().toLowerCase())\n    .filter((value): value is WorktreeMergeScope =>\n      (WORKTREE_MERGE_SCOPES as readonly string[]).includes(value),\n    );\n\n  if (parsed.length === 0) {\n    throw new Error(\n      `Invalid scope \"${rawValue}\". Expected a comma-separated list of: ${WORKTREE_MERGE_SCOPES.join(\", \")}.`,\n    );\n  }\n\n  return [...new Set(parsed)];\n}\n\nexport function buildWorktreeMergePlan(input: {\n  companyId: string;\n  companyName: string;\n  issuePrefix: string;\n  previewIssueCounterStart: number;\n  scopes: WorktreeMergeScope[];\n  sourceIssues: IssueRow[];\n  targetIssues: IssueRow[];\n  sourceComments: CommentRow[];\n  targetComments: CommentRow[];\n  sourceProjects?: ProjectRow[];","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree-merge-history-lib.ts#L314-L350","documentation":"Thrown by parseWorktreeMergeScopes when the supplied --scope value is non-empty but, after lowercasing and trimming, contains zero tokens that match the allowed WORKTREE_MERGE_SCOPES set (currently 'issues' and 'comments'). Empty/undefined input is valid (defaults to both scopes); only malformed non-empty input triggers this.","triggerScenarios":"Calling `paperclipai worktree ... --scope <value>` (or parseWorktreeMergeScopes programmatically) with a value like 'issue', 'comment', 'all', 'tickets', or a typo such as 'isues'. After split/filter against ['issues','comments'] the parsed array is empty.","commonSituations":"Typing a singular form ('issue' instead of 'issues'). Using a synonym the tool does not recognize ('threads', 'posts'). Misreading docs and passing 'all' or 'everything'. Stray whitespace/punctuation producing zero valid tokens.","solutions":["Use only the allowed tokens, comma-separated: `--scope issues`, `--scope comments`, or `--scope issues,comments`.","Omit --scope entirely to accept the default ['issues','comments'].","Check spelling: both scope names are plural lowercase."],"exampleFix":"# before\npaperclipai worktree merge-history --scope issue,comment\n# after\npaperclipai worktree merge-history --scope issues,comments","handlingStrategy":"validation","validationCode":"import { WORKTREE_MERGE_SCOPES, type WorktreeMergeScope } from '../commands/worktree-merge-history-lib.js';\nfunction safeScopes(rawValue: string | undefined): WorktreeMergeScope[] {\n  if (!rawValue?.trim()) return ['issues', 'comments'];\n  const parsed = rawValue.split(',').map((v) => v.trim().toLowerCase()).filter((v): v is WorktreeMergeScope => (WORKTREE_MERGE_SCOPES as readonly string[]).includes(v));\n  return parsed.length > 0 ? [...new Set(parsed)] : ['issues', 'comments']; // fallback instead of throw\n}\n// use safeScopes(opts.scope) to avoid the throw","typeGuard":"function isWorktreeMergeScope(v: string): v is WorktreeMergeScope {\n  return (WORKTREE_MERGE_SCOPES as readonly string[]).includes(v.trim().toLowerCase());\n}","tryCatchPattern":null,"preventionTips":["Constrain the --scope input in your UI/CLI to a checkbox/dropdown of the two allowed values.","Validate tokens against WORKTREE_MERGE_SCOPES before calling parseWorktreeMergeScopes.","Remember empty input is valid (defaults to both scopes); only non-empty invalid tokens throw."],"tags":["validation","scope","worktree-merge"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}