paperclipai/paperclip · error · Error

companyId is required for this operation

Error message

companyId is required for this operation

What it means

buildHostServices was constructed without a companyId. All plugin host service API calls are company-scoped, so this guard rejects any operation attempted before a company context is bound.

Source

Thrown at server/src/services/plugin-host-services.ts:766

  const projects = projectService(db);
  const executionWorkspaces = executionWorkspaceService(db);
  const issues = issueService(db);
  const documents = documentService(db);
  const goals = goalService(db);
  const access = accessService(db);
  const authorization = authorizationService(db);
  const budgets = budgetService(db);
  const issueApprovals = issueApprovalService(db);
  const approvalSvc = approvalService(db);
  const interactions = issueThreadInteractionService(db);
  const scopedBus = eventBus.forPlugin(pluginKey);

  // Track active session event subscriptions for cleanup
  const activeSubscriptions = new Set<{ unsubscribe: () => void; timer: ReturnType<typeof setTimeout> }>();
  let disposed = false;

  const ensureCompanyId = (companyId?: string) => {
    if (!companyId) throw new Error("companyId is required for this operation");
    return companyId;
  };

  const parseWindowValue = (value: unknown): number | null => {
    if (typeof value === "number" && Number.isFinite(value)) {
      return Math.max(0, Math.floor(value));
    }
    if (typeof value === "string" && value.trim().length > 0) {
      const parsed = Number(value);
      if (Number.isFinite(parsed)) {
        return Math.max(0, Math.floor(parsed));
      }
    }
    return null;
  };

  const applyWindow = <T>(rows: T[], params?: { limit?: unknown; offset?: unknown }): T[] => {
    const offset = parseWindowValue(params?.offset) ?? 0;

View on GitHub (pinned to a7e689b3c3)

Solutions

  1. Provide companyId in the request/context for this plugin host service operation.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/src/services/plugin-host-services.ts:757 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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