{"record":{"id":"a212f97ed3e3da7b","repo":"paperclipai/paperclip","slug":"select-a-company-before-saving-plugin-configuratio","errorCode":null,"errorMessage":"Select a company before saving plugin configuration.","messagePattern":"Select a company before saving plugin configuration\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ui/src/pages/PluginSettings.tsx","lineNumber":985,"sourceCode":"        ...initialValues,\n      });\n    }\n  }, [initialValues, schema]);\n\n  const [errors, setErrors] = useState<Record<string, string>>({});\n  const [saveMessage, setSaveMessage] = useState<{ type: \"success\" | \"error\"; text: string } | null>(null);\n  const [testResult, setTestResult] = useState<{ type: \"success\" | \"error\"; text: string } | null>(null);\n\n  // Dirty tracking: compare against initial values\n  const isDirty = JSON.stringify(values) !== JSON.stringify({\n    ...getDefaultValues(schema),\n    ...(initialValues ?? {}),\n  });\n\n  // Save mutation\n  const saveMutation = useMutation({\n    mutationFn: (configJson: Record<string, unknown>) => {\n      if (!companyId) throw new Error(\"Select a company before saving plugin configuration.\");\n      return pluginsApi.saveConfig(pluginId, companyId, configJson);\n    },\n    onSuccess: () => {\n      setSaveMessage({ type: \"success\", text: \"Configuration saved.\" });\n      setTestResult(null);\n      if (companyId) {\n        queryClient.invalidateQueries({ queryKey: queryKeys.plugins.config(pluginId, companyId) });\n      }\n      // Clear success message after 3s\n      setTimeout(() => setSaveMessage(null), 3000);\n    },\n    onError: (err: Error) => {\n      setSaveMessage({ type: \"error\", text: err.message || \"Failed to save configuration.\" });\n    },\n  });\n\n  // Test configuration mutation\n  const testMutation = useMutation({","sourceCodeStart":967,"sourceCodeEnd":1003,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/ui/src/pages/PluginSettings.tsx#L967-L1003","documentation":"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.","triggerScenarios":"Thrown at ui/src/pages/PluginSettings.tsx:986 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Select a company from the company picker before saving the plugin configuration."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}