{"record":{"id":"14921edd6690a592","repo":"paperclipai/paperclip","slug":"could-not-resolve-company-selector-in-both-so","errorCode":null,"errorMessage":"Could not resolve company \"${selector}\" in both source and target databases.","messagePattern":"Could not resolve company \"(.+?)\" in both source and target databases\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":2330,"sourceCode":"      .from(companies),\n    input.targetDb\n      .select({\n        id: companies.id,\n        name: companies.name,\n        issuePrefix: companies.issuePrefix,\n      })\n      .from(companies),\n  ]);\n\n  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","sourceCodeStart":2312,"sourceCodeEnd":2348,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L2312-L2348","documentation":"Thrown by resolveMergeCompany when an explicit company selector was passed (--company) but no company in the SHARED set matches it by id OR by issuePrefix (case-insensitive). 'Shared' means companies whose id exists in BOTH source and target databases. The selector must therefore identify one of the companies present on both sides, not just one side.","triggerScenarios":"Passing `--company <id>` where the id exists only in source or only in target; passing an issuePrefix that belongs to a non-shared company; typo in the selector; copy-pasting a source-only company id.","commonSituations":"Freshly seeded target that doesn't yet contain the source company; merged company id mismatch after a re-seed; selector taken from the wrong database.","solutions":["List shared companies by running merge-history WITHOUT --company and reading the 'Multiple shared companies' options, or query both DBs for matching company ids.","Use the company id (preferred) or exact issuePrefix of a company present in both source and target.","If the target lacks the company, ensure it was seeded/created before merging.","Check for trailing whitespace / case in the selector."],"exampleFix":"// before\npaperclipai worktree:merge-history --company ABC   # ABC only in source\n// after (use a shared id)\npaperclipai worktree:merge-history --company 01HXXXXXXXXXXXXXXXXXXXXXX","handlingStrategy":"validation","validationCode":"const shared = sourceCompanies.filter((c) => targetById.has(c.id));\nconst matched = shared.find((c) => c.id === selector || c.issuePrefix.toLowerCase() === selector.toLowerCase());\nif (!matched) throw new Error(`Selector not in shared set`);","typeGuard":"function selectorMatchesShared(selector: string, shared: { id: string; issuePrefix: string }[]): boolean {\n  const s = selector.toLowerCase();\n  return shared.some((c) => c.id === selector || c.issuePrefix.toLowerCase() === s);\n}","tryCatchPattern":null,"preventionTips":["Run merge-history without --company first to see shared candidates.","Use the company id rather than issuePrefix to avoid case/typo issues.","Ensure the target was seeded from the same source so company ids overlap."],"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"}