{"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":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":3145,"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":3127,"sourceCodeEnd":3163,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/worktree.ts#L3127-L3163","documentation":"Cross-database company resolution failure: the --company selector (id or issue prefix) matches no company that exists in BOTH the source and target databases, so the merge cannot know which company's data to copy.","triggerScenarios":"Thrown at cli/src/commands/worktree.ts:2330 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass --company with a company id or name that exists in both databases.","Verify the company selector and that both instances share the company."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}