paperclipai/paperclip · error · Error

Select a company before saving plugin configuration.

Error message

Select a company before saving plugin configuration.

What it means

Scope guard in the PluginConfigForm saveMutation: plugin configuration is stored per company, but no company is currently selected in context, so there is no companyId under which to persist the config. The save aborts before any API call.

Source

Thrown at ui/src/pages/PluginSettings.tsx:985

        ...initialValues,
      });
    }
  }, [initialValues, schema]);

  const [errors, setErrors] = useState<Record<string, string>>({});
  const [saveMessage, setSaveMessage] = useState<{ type: "success" | "error"; text: string } | null>(null);
  const [testResult, setTestResult] = useState<{ type: "success" | "error"; text: string } | null>(null);

  // Dirty tracking: compare against initial values
  const isDirty = JSON.stringify(values) !== JSON.stringify({
    ...getDefaultValues(schema),
    ...(initialValues ?? {}),
  });

  // Save mutation
  const saveMutation = useMutation({
    mutationFn: (configJson: Record<string, unknown>) => {
      if (!companyId) throw new Error("Select a company before saving plugin configuration.");
      return pluginsApi.saveConfig(pluginId, companyId, configJson);
    },
    onSuccess: () => {
      setSaveMessage({ type: "success", text: "Configuration saved." });
      setTestResult(null);
      if (companyId) {
        queryClient.invalidateQueries({ queryKey: queryKeys.plugins.config(pluginId, companyId) });
      }
      // Clear success message after 3s
      setTimeout(() => setSaveMessage(null), 3000);
    },
    onError: (err: Error) => {
      setSaveMessage({ type: "error", text: err.message || "Failed to save configuration." });
    },
  });

  // Test configuration mutation
  const testMutation = useMutation({

View on GitHub (pinned to a7e689b3c3)

Solutions

  1. Select a company from the company picker before saving the plugin configuration.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at ui/src/pages/PluginSettings.tsx:986 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/a212f97ed3e3da7b. Report an issue: GitHub.