lobehub / lobe-chat

🤯 Lobe Chat - an open-source, modern-design AI chat framework. Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Ollama / Azure / DeepSeek), Knowledge Base (file upload / knowledge management / RAG ), Multi-Modals (Vision/TTS) and plugin system. One-click FREE deployment of your private ChatGPT/ Claude application.
https://chat-preview.lobehub.com
Other
44.12k stars 9.86k forks source link

[Bug] 本地插件无法更新,只能卸载重装 #3770

Open chung1912 opened 1 month ago

chung1912 commented 1 month ago

📦 部署环境

Docker

📌 软件版本

v1.15.10(Database版)

💻 系统环境

Windows

🌐 浏览器

Chrome

🐛 问题描述

本地插件更新会提示错误:duplicate key value violates unique constraint "user_installed_plugins_user_id_identifier_pk" image

📷 复现步骤

No response

🚦 期望结果

期望可以正常更新,不要卸载重装。卸载重装后,设置信息需要重新填写,比较麻烦

📝 补充信息

No response

lobehubbot commented 1 month ago

👀 @chung1912

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.\ 非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

lobehubbot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


📦 Deployment environment

Docker

📌 Software version

v1.15.10(Database version)

💻 System environment

Windows

🌐 Browser

Chrome

🐛 Problem description

Local plug-in updates will prompt an error: duplicate key value violates unique constraint "user_installed_plugins_user_id_identifier_pk" image

📷 Steps to reproduce

No response

🚦 Expected results

Expect to be able to update normally, do not uninstall and reinstall. After uninstalling and reinstalling, the setting information needs to be filled in again, which is quite troublesome.

📝 Supplementary information

No response

dosubot[bot] commented 1 month ago

要解决在 Docker 上的 Windows 环境中使用 Chrome 浏览器时更新本地插件时出现的 "duplicate key value violates unique constraint" 错误,请确保 user_installed_plugins 表中的 identifier 字段是唯一的。此错误是由于尝试插入或更新具有唯一约束的列中的重复值而引起的。

user_installed_plugins 表的结构如下:

要解决此问题,可以按照以下步骤操作:

  1. 检查现有记录:在插入或更新插件之前,检查 user_installed_plugins 表中是否已经存在具有相同 identifier 的记录。

  2. 更新现有记录:如果存在具有相同 identifier 的记录,请更新现有记录而不是插入新记录。

  3. 生成唯一标识符:确保新插件具有唯一的 identifier 值,以避免冲突。

以下是检查现有记录并在必要时更新它们的示例:

-- 检查是否存在具有相同 identifier 的插件
SELECT id FROM user_installed_plugins WHERE identifier = 'your_plugin_identifier';

-- 如果存在记录,则更新它
UPDATE user_installed_plugins
SET name = 'new_name', manifest = 'new_manifest', settings = 'new_settings', updated_at = NOW()
WHERE identifier = 'your_plugin_identifier';

-- 如果不存在记录,则插入新记录
INSERT INTO user_installed_plugins (identifier, name, manifest, settings, created_at, updated_at)
VALUES ('your_plugin_identifier', 'new_name', 'new_manifest', 'new_settings', NOW(), NOW());

通过确保 identifier 的唯一性并适当地处理更新,可以避免 "duplicate key value violates unique constraint" 错误 [1][2].

To continue talking to Dosu, mention @dosu.

arvinxx commented 1 month ago

感觉是我实现的 bug,当时没测自定义插件的逻辑

lobehubbot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It feels like it was a bug in my implementation. I didn’t test the logic of the custom plug-in at the time.