{"record":{"id":"2799d74bb715eaf4","repo":"paperclipai/paperclip","slug":"source-and-target-databases-do-not-share-a-company","errorCode":null,"errorMessage":"Source and target databases do not share a company id. Pass --company explicitly once both sides match.","messagePattern":"Source and target databases do not share a company id\\. Pass --company explicitly once both sides match\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":2340,"sourceCode":"  const targetById = new Map(targetCompanies.map((company) => [company.id, company]));\n  const shared = sourceCompanies.filter((company) => targetById.has(company.id));\n  const selector = nonEmpty(input.selector);\n  if (selector) {\n    const matched = shared.find(\n      (company) => company.id === selector || company.issuePrefix.toLowerCase() === selector.toLowerCase(),\n    );\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;","sourceCodeStart":2322,"sourceCodeEnd":2358,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L2322-L2358","documentation":"Thrown by resolveMergeCompany when no --company selector was given and the source and target databases share ZERO company ids. Merge-history copies issues for one company across both DBs, so without any common company id there is nothing to merge. This typically indicates the target was seeded from a different source, or the companies were created independently with different ids.","triggerScenarios":"Target worktree seeded from source A but merge attempted against source B; target created fresh (empty/minimal) so it has no companies yet; company ids diverged after independent creation.","commonSituations":"Cross-merging two unrelated Paperclip instances; target DB reset after seeding; company created in source after the seed snapshot was taken.","solutions":["Re-seed the target from the intended source so company ids match: `paperclipai worktree:seed --from-config <source>`.","Create the same company (same id) in the target before merging.","Confirm you are pointing merge-history at the correct source and target endpoints."],"exampleFix":"// before: no shared company id between source and target\n// after\npaperclipai worktree:seed --from-config /correct-source/.paperclip/config.json\npaperclipai worktree:merge-history","handlingStrategy":"validation","validationCode":"const shared = sourceCompanies.filter((c) => targetById.has(c.id));\nif (shared.length === 0) throw new Error(\"No shared company id; re-seed target from source\");","typeGuard":"function hasSharedCompany(source: {id:string}[], target: {id:string}[]): boolean {\n  const tids = new Set(target.map((c) => c.id));\n  return source.some((c) => tids.has(c.id));\n}","tryCatchPattern":null,"preventionTips":["Seed the target from the intended source before merging.","Verify source and target endpoints point at related instances.","Create the same company in both DBs if merging unrelated instances."],"tags":["worktree","merge","company","database"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}