paperclipai/paperclip · error · Error

Multiple shared companies found. Re-run with --company <id-o

Error message

Multiple shared companies found. Re-run with --company <id-or-prefix>. Options: ${options}

What it means

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.

Source

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

    );
    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;
    return `${value.slice(0, Math.max(0, maxWidth - 1)).trimEnd()}…`;
  };
  const lines = [
    `Mode: preview`,
    `Source: ${extras.sourcePath}`,
    `Target: ${extras.targetPath}`,

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Read the listed options from the error message (issuePrefix + name).
  2. Re-run with `--company <id-or-issuePrefix>` for the desired company.
  3. Prefer the company id for an exact match.

Example fix

// before
paperclipai worktree:merge-history   # multiple shared companies
// after
paperclipai worktree:merge-history --company ENG
Defensive patterns

Strategy: validation

Validate before calling

if (shared.length > 1) {
  throw new Error(`Ambiguous: ${shared.map((c) => c.issuePrefix).join(", ")}. Pass --company.`);
}

Type guard

function sharedIsUnique(shared: unknown[]): boolean { return shared.length === 1; }

Prevention

When it happens

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

Common situations: Paperclip instance manages several companies; target seeded from a source that itself has multiple companies; consolidated/merged databases.

Related errors


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