paperclipai/paperclip · error · Error

Source and target databases do not share a company id. Pass

Error message

Source and target databases do not share a company id. Pass --company explicitly once both sides match.

What it means

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.

Source

Thrown at cli/src/commands/worktree.ts:2340

  const targetById = new Map(targetCompanies.map((company) => [company.id, company]));
  const shared = sourceCompanies.filter((company) => targetById.has(company.id));
  const selector = nonEmpty(input.selector);
  if (selector) {
    const matched = shared.find(
      (company) => company.id === selector || company.issuePrefix.toLowerCase() === selector.toLowerCase(),
    );
    if (!matched) {
      throw new Error(`Could not resolve company "${selector}" in both source and target databases.`);
    }
    return matched;
  }

  if (shared.length === 1) {
    return shared[0];
  }

  if (shared.length === 0) {
    throw new Error("Source and target databases do not share a company id. Pass --company explicitly once both sides match.");
  }

  const options = shared
    .map((company) => `${company.issuePrefix} (${company.name})`)
    .join(", ");
  throw new Error(`Multiple shared companies found. Re-run with --company <id-or-prefix>. Options: ${options}`);
}

function renderMergePlan(plan: Awaited<ReturnType<typeof collectMergePlan>>["plan"], extras: {
  sourcePath: string;
  targetPath: string;
  unsupportedRunCount: number;
}): string {
  const terminalWidth = Math.max(60, process.stdout.columns ?? 100);
  const oneLine = (value: string) => value.replace(/\s+/g, " ").trim();
  const truncateToWidth = (value: string, maxWidth: number) => {
    if (maxWidth <= 1) return "";
    if (value.length <= maxWidth) return value;

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Re-seed the target from the intended source so company ids match: `paperclipai worktree:seed --from-config <source>`.
  2. Create the same company (same id) in the target before merging.
  3. Confirm you are pointing merge-history at the correct source and target endpoints.

Example fix

// before: no shared company id between source and target
// after
paperclipai worktree:seed --from-config /correct-source/.paperclip/config.json
paperclipai worktree:merge-history
Defensive patterns

Strategy: validation

Validate before calling

const shared = sourceCompanies.filter((c) => targetById.has(c.id));
if (shared.length === 0) throw new Error("No shared company id; re-seed target from source");

Type guard

function hasSharedCompany(source: {id:string}[], target: {id:string}[]): boolean {
  const tids = new Set(target.map((c) => c.id));
  return source.some((c) => tids.has(c.id));
}

Prevention

When it happens

Trigger: 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.

Common situations: Cross-merging two unrelated Paperclip instances; target DB reset after seeding; company created in source after the seed snapshot was taken.

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/2799d74bb715eaf4. Report an issue: GitHub.