paperclipai/paperclip · error · Error

Existing-company imports require a companyId to resolve the…

Error message

Existing-company imports require a companyId to resolve the API route.

What it means

resolveCompanyImportApiPath was asked to build an existing-company import route but the companyId option was empty or whitespace, so it cannot construct the company-scoped API path.

Solutions

  1. Pass --company-id (or set PAPERCLIP_COMPANY_ID / a context profile companyId) when importing into an existing company.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cli/src/commands/client/company.ts:781 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/f1487ac85f990ecc. Report an issue: GitHub.

Appendix: source

Thrown at cli/src/commands/client/company.ts:781

function printCompanyImportView(title: string, body: string, opts?: { interactive?: boolean }): void {
  if (opts?.interactive) {
    p.note(body, title);
    return;
  }
  console.log(pc.bold(title));
  console.log(body);
}

export function resolveCompanyImportApiPath(input: {
  dryRun: boolean;
  targetMode: "new_company" | "existing_company";
  companyId?: string | null;
}): string {
  if (input.targetMode === "existing_company") {
    const companyId = input.companyId?.trim();
    if (!companyId) {
      throw new Error("Existing-company imports require a companyId to resolve the API route.");
    }
    return input.dryRun
      ? apiPath`/api/companies/${companyId}/imports/preview`
      : apiPath`/api/companies/${companyId}/imports/apply`;
  }

  return input.dryRun ? "/api/companies/import/preview" : "/api/companies/import";
}

export function buildCompanyDashboardUrl(apiBase: string, issuePrefix: string): string {
  const url = new URL(apiBase);
  const normalizedPrefix = issuePrefix.trim().replace(/^\/+|\/+$/g, "");
  url.pathname = `${url.pathname.replace(/\/+$/, "")}/${normalizedPrefix}/dashboard`;
  url.search = "";
  url.hash = "";
  return url.toString();
}

View on GitHub (pinned to 120ae5428f)