{"record":{"id":"8286c70304f88c2e","repo":"siyuan-note/siyuan","slug":"plugin-s-not-found","errorCode":null,"errorMessage":"plugin [%s] not found","messagePattern":"plugin \\[(.+?)\\] not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/plugin.go","lineNumber":68,"sourceCode":"}\n\ntype KernelPetal struct {\n\tJS           string `json:\"js\"`           // Kernel JS code\n\tExisted      bool   `json:\"existed\"`      // Whether kernel.js is exist\n\tIncompatible bool   `json:\"incompatible\"` // Whether incompatible\n}\n\nvar (\n\tOnKernelPluginStart  func(petal *Petal) // Called when a plugin is enabled (after loading and starting the plugin)\n\tOnKernelPluginStop   func(petal *Petal) // Called when a plugin is disabled (before stopping and unloading the plugin)\n\tOnKernelPluginsStart func()             // Called to start all valid plugins\n\tOnKernelPluginsStop  func()             // Called to stopping all valid plugins\n)\n\nfunc SetPetalEnabled(name string, enabled bool) (ret *Petal, err error) {\n\tfound, version, displayName, incompatible, disabledInPublish, disallowInstall, kernelIncompatible := bazaar.ParseInstalledPlugin(name, \"\")\n\tif !found {\n\t\terr = fmt.Errorf(\"plugin [%s] not found\", name)\n\t\tlogging.LogErrorf(\"%s\", err)\n\t\treturn\n\t}\n\n\tret, err = updatePetal(name, func(petal *Petal) error {\n\t\tpetal.Version = version\n\t\tpetal.DisplayName = displayName\n\t\tpetal.Enabled = enabled\n\t\tpetal.Incompatible = incompatible\n\t\tpetal.DisabledInPublish = disabledInPublish\n\t\tpetal.DisallowInstall = disallowInstall\n\t\tpetal.Kernel = KernelPetal{\n\t\t\tIncompatible: kernelIncompatible,\n\t\t}\n\n\t\tif enabled && disallowInstall {\n\t\t\treturn fmt.Errorf(\"require upgrade SiYuan to use this plugin [%s]\", name)\n\t\t}","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/plugin.go#L50-L86","documentation":"SetPetalEnabled toggles a plugin's enabled state. Before touching the petal config it calls bazaar.ParseInstalledPlugin(name, \"\"), which looks the plugin up among installed plugins. If no installed plugin matches the given name, the function returns this error and logs it, so the caller knows the plugin is not present in the workspace's plugin directory.","triggerScenarios":"Calling SetPetalEnabled with a plugin name that is not installed: typo in the name, plugin uninstalled between listing and enabling, plugin installed under a different directory name than the one used in the call.","commonSituations":"Plugin removed by the user or another window before the enable call; marketplace install failed leaving metadata without the plugin directory; script uses the marketplace package name instead of the installed plugin name.","solutions":["List installed plugins (bazaar/installed plugins API) and use the exact returned name.","Reinstall the plugin from the marketplace, then retry.","Check the plugin directory exists under the workspace conf/appearance/plugins path.","Handle the error in the caller and surface 'plugin not installed' to the user."],"exampleFix":"// before\npetal, err := model.SetPetalEnabled(\"my-plugin\", true)\n// after\ninstalled := bazaar.InstalledPlugins(\"\", 0) // verify name first\nif !containsPlugin(installed, \"my-plugin\") {\n    return errors.New(\"plugin my-plugin is not installed\")\n}\npetal, err := model.SetPetalEnabled(\"my-plugin\", true)","handlingStrategy":"try-catch","validationCode":"found, _, _, _, _, _, _ := bazaar.ParseInstalledPlugin(name, \"\")\nif !found { return fmt.Errorf(\"plugin %q is not installed\", name) }","typeGuard":null,"tryCatchPattern":"petal, err := model.SetPetalEnabled(name, true)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n    // refresh installed-plugin list; prompt reinstall\n}","preventionTips":["Resolve plugin names from the installed-plugins listing, not user input","Handle uninstall/unenable races between windows","Verify install success after marketplace operations","Log plugin names at call sites to spot stale references"],"tags":["plugin","not-found","petal"],"backgroundTag":"resource-not-found","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}