{"record":{"id":"0dd337477db4ecf0","repo":"paperclipai/paperclip","slug":"multiple-shared-companies-found-re-run-with-com","errorCode":null,"errorMessage":"Multiple shared companies found. Re-run with --company <id-or-prefix>. Options: ${options}","messagePattern":"Multiple shared companies found\\. Re-run with --company <id-or-prefix>\\. Options: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":2346,"sourceCode":"    );\n    if (!matched) {\n      throw new Error(`Could not resolve company \"${selector}\" in both source and target databases.`);\n    }\n    return matched;\n  }\n\n  if (shared.length === 1) {\n    return shared[0];\n  }\n\n  if (shared.length === 0) {\n    throw new Error(\"Source and target databases do not share a company id. Pass --company explicitly once both sides match.\");\n  }\n\n  const options = shared\n    .map((company) => `${company.issuePrefix} (${company.name})`)\n    .join(\", \");\n  throw new Error(`Multiple shared companies found. Re-run with --company <id-or-prefix>. Options: ${options}`);\n}\n\nfunction renderMergePlan(plan: Awaited<ReturnType<typeof collectMergePlan>>[\"plan\"], extras: {\n  sourcePath: string;\n  targetPath: string;\n  unsupportedRunCount: number;\n}): string {\n  const terminalWidth = Math.max(60, process.stdout.columns ?? 100);\n  const oneLine = (value: string) => value.replace(/\\s+/g, \" \").trim();\n  const truncateToWidth = (value: string, maxWidth: number) => {\n    if (maxWidth <= 1) return \"\";\n    if (value.length <= maxWidth) return value;\n    return `${value.slice(0, Math.max(0, maxWidth - 1)).trimEnd()}…`;\n  };\n  const lines = [\n    `Mode: preview`,\n    `Source: ${extras.sourcePath}`,\n    `Target: ${extras.targetPath}`,","sourceCodeStart":2328,"sourceCodeEnd":2364,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L2328-L2364","documentation":"Thrown by resolveMergeCompany when no --company selector was given and MORE than one company id is shared between source and target. Because merge-history operates on a single company, an ambiguous shared set cannot be auto-resolved; the error lists the candidate companies as '<issuePrefix> (<name>)' so the user can pick one and pass --company.","triggerScenarios":"Both databases contain multiple companies with overlapping ids (e.g. a multi-company instance); merge-history invoked without --company on a shared set of size >= 2.","commonSituations":"Paperclip instance manages several companies; target seeded from a source that itself has multiple companies; consolidated/merged databases.","solutions":["Read the listed options from the error message (issuePrefix + name).","Re-run with `--company <id-or-issuePrefix>` for the desired company.","Prefer the company id for an exact match."],"exampleFix":"// before\npaperclipai worktree:merge-history   # multiple shared companies\n// after\npaperclipai worktree:merge-history --company ENG","handlingStrategy":"validation","validationCode":"if (shared.length > 1) {\n  throw new Error(`Ambiguous: ${shared.map((c) => c.issuePrefix).join(\", \")}. Pass --company.`);\n}","typeGuard":"function sharedIsUnique(shared: unknown[]): boolean { return shared.length === 1; }","tryCatchPattern":null,"preventionTips":["Always pass --company when an instance has multiple companies.","Read the candidate list from the error message to choose."],"tags":["worktree","merge","company","validation"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}