{"record":{"id":"586702ff5c498a27","repo":"tauri-apps/tauri","slug":"valid-plugin","errorCode":null,"errorMessage":"valid plugin","messagePattern":"valid plugin","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri/src/plugin.rs","lineNumber":801,"sourceCode":"      js_init_script: self.js_init_script,\n      on_navigation: self.on_navigation,\n      on_page_load: self.on_page_load,\n      on_window_ready: self.on_window_ready,\n      on_webview_ready: self.on_webview_ready,\n      on_event: self.on_event,\n      on_cleanup_before_exit: self.on_cleanup_before_exit,\n      on_drop: self.on_drop,\n      uri_scheme_protocols: self.uri_scheme_protocols,\n    })\n  }\n\n  /// Builds the [`TauriPlugin`].\n  ///\n  /// # Panics\n  ///\n  /// If the builder returns an error during [`Self::try_build`], then this method will panic.\n  pub fn build(self) -> TauriPlugin<R, C> {\n    self.try_build().expect(\"valid plugin\")\n  }\n}\n\n/// Plugin struct that is returned by the [`Builder`]. Should only be constructed through the builder.\npub struct TauriPlugin<R: Runtime, C: DeserializeOwned = ()> {\n  name: &'static str,\n  app: Option<AppHandle<R>>,\n  invoke_handler: Box<InvokeHandler<R>>,\n  setup: Option<Box<SetupHook<R, C>>>,\n  js_init_script: Option<InitializationScript>,\n  on_navigation: Box<OnNavigation<R>>,\n  on_page_load: Box<OnPageLoad<R>>,\n  on_window_ready: Box<OnWindowReady<R>>,\n  on_webview_ready: Box<OnWebviewReady<R>>,\n  on_event: Box<OnEvent<R>>,\n  on_cleanup_before_exit: Box<OnCleanupBeforeExit<R>>,\n  on_drop: Option<Box<OnDrop<R>>>,\n  uri_scheme_protocols: HashMap<String, Arc<UriSchemeProtocol<R>>>,","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri/src/plugin.rs#L783-L819","documentation":"`Builder::build` is the panicking variant of plugin construction: it calls `try_build` and `expect(\"valid plugin\")` on the result. If the plugin builder's setup, initialization, or config deserialization returns an error, this panic fires with that underlying error message.","triggerScenarios":"Calling `.build()` on a `tauri::plugin::Builder` whose `setup`/`on_event`/`initialization_script` closures fail, or whose config `C` fails to deserialize from the plugin config section.","commonSituations":"Plugin config in `tauri.conf.json` not matching the plugin's expected config struct; plugin `setup` returning `Err` due to missing resources; third-party plugin versions incompatible with the installed tauri version.","solutions":["Switch to `try_build()` and handle the `Result` to get the real underlying error instead of a panic.","Validate your plugin config section in `tauri.conf.json` against the plugin's documented config schema.","Check the plugin's `setup` closure for fallible operations and return descriptive errors there.","Align plugin and tauri versions (same minor version family) to avoid API drift."],"exampleFix":"// before\nlet plugin = tauri::plugin::Builder::new(\"myplugin\").build(); // panics on error\n// after\nlet plugin = tauri::plugin::Builder::<_, serde_json::Value>::new(\"myplugin\")\n  .try_build()\n  .expect(\"plugin config invalid — see tauri.conf.json\");","handlingStrategy":"try-catch","validationCode":"// Validate plugin config before build\nlet cfg: MyPluginConfig = serde_json::from_value(\n  app.config().plugins.0.get(\"myplugin\").cloned().unwrap_or_default()\n).map_err(|e| format!(\"bad myplugin config: {e}\"))?;","typeGuard":null,"tryCatchPattern":"// Use try_build instead of build\nlet plugin = tauri::plugin::Builder::new(\"myplugin\")\n  .try_build()\n  .map_err(|e| anyhow!(\"plugin init failed: {e}\"))?;","preventionTips":["Prefer try_build() over build() in application code","Validate plugin config sections against the plugin schema","Pin plugin versions compatible with your tauri version"],"tags":["plugin","panic","configuration"],"backgroundTag":"internal-invariant-violation","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}