fix file not found error when deleting custom plugins
Replaced the "delete_work_dir_file" API call with a "delete_plugin" action in the plugins API. This bypasses the dev container file browser conversion and directly uses the runtime's absolute path to securely remove custom plugins using the files.delete_dir utility.
Alessandro committed
Mar 4, 2026 at 14:34 UTC
8c90ad54aeaf0e850b1cd0a997d42c35452a8454
2 files changed
+22
-2
python/api/plugins.py
+19
@@ -155,6 +155,25 @@ class Plugins(ApiHandler):
155
156
return {"ok": True}
157
158
+ if action == "delete_plugin":
159
+ plugin_name = input.get("plugin_name", "")
160
+ path = input.get("path", "")
161
+ if not plugin_name:
162
+ return Response(status=400, response="Missing plugin_name")
163
+ if not path:
164
+ return Response(status=400, response="Missing path")
165
+
166
+ # Validate that the plugin is actually a custom plugin
167
+ custom_plugins_dir = files.get_abs_path(files.USER_DIR, files.PLUGINS_DIR)
168
+ if not os.path.abspath(path).startswith(os.path.abspath(custom_plugins_dir)):
169
+ return Response(status=400, response="Only custom plugins can be deleted")
170
+
171
+ try:
172
+ files.delete_dir(path)
173
+ except Exception as e:
174
+ return Response(status=500, response=f"Failed to delete plugin: {str(e)}")
175
+ return {"ok": True}
176
+
177
if action == "get_default_config":
178
plugin_name = input.get("plugin_name", "")
179
if not plugin_name:
webui/components/plugins/list/pluginListStore.js
+3
-2
@@ -163,9 +163,10 @@ const model = {
163
}
164
165
try {
166
- const response = await api.callJsonApi("delete_work_dir_file", {
166
+ const response = await api.callJsonApi("plugins", {
167
+ action: "delete_plugin",
168
+ plugin_name: plugin.name,
169
path: plugin.path,
168
- currentPath: "/",
170
});
171
if (response?.error) {
172
throw new Error(response.error);