Skip to content

fix: plugin name in the marketplace does not match the local plugin#8274

Closed
Waterwzy wants to merge 3 commits into
AstrBotDevs:masterfrom
Waterwzy:fix/plugin_update
Closed

fix: plugin name in the marketplace does not match the local plugin#8274
Waterwzy wants to merge 3 commits into
AstrBotDevs:masterfrom
Waterwzy:fix/plugin_update

Conversation

@Waterwzy
Copy link
Copy Markdown
Contributor

@Waterwzy Waterwzy commented May 21, 2026

相关前置PR:#7493

在插件市场获取插件时,获取到的插件分隔符为 - 但是本地插件的metadata全部为 _ 会导致插件名称的匹配问题。

同时,在检查插件更新时,checkUpdate()getExtensions() 中被调用时, pluginMarketData (远程插件市场数据)尚未加载完成,导致匹配时 ·pluginMarketData· 为空,无法找到匹配的远程插件。

本PR通过修改获取插件市场插件的时机,在后端API接口统一插件名称的方式解决了这些问题。

Modifications / 改动点

  1. 后端 ( astrbot/dashboard/routes/plugin.py )
    修改了 3 个接口方法,统一在返回数据时转换名称格式:
  • get_plugins() - 返回本地插件列表
  • get_plugin_detail() - 返回插件详情
  • get_plugin_page_components() - 返回插件页面组件信息
  1. 前端 ( dashboard/src/views/extension/useExtensionPage.js )
  • 调整 checkUpdate() 调用时机 :

    • getExtensions() 中移除调用(避免在 pluginMarketData 加载前执行)
    • finalizeSuccessfulInstall() 中添加调用(确保安装后立即检查更新)
  • 清理 checkAlreadyInstalled() 函数 :移除不再需要的 replace(/_/g, "-") 操作

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

当插件repo不匹配但是名称匹配时:

dc920828fa7e3771c74f44034055c14d 5ec5715b3493291bbead642cbcb3b12b

检查是否安装和是否更新的行为均按预期进行。


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Align plugin naming between local data and the marketplace and adjust update checks to rely on normalized names and correctly loaded market data.

Bug Fixes:

  • Ensure local plugins use hyphenated names in API responses to match marketplace plugin naming and avoid mismatched installs and updates.
  • Normalize plugin names consistently on the frontend when mapping and matching marketplace plugins to installed extensions, preventing name-based mismatches.
  • Delay plugin update checks until marketplace data is loaded and trigger them after successful installs to avoid running with empty market data.

Build:

  • Add @ricky0123/vad-web and onnxruntime-web as new dashboard dependencies.

@auto-assign auto-assign Bot requested review from Fridemn and anka-afk May 21, 2026 14:02
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. feature:plugin The bug / feature is about AstrBot plugin system. labels May 21, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The backend now does plugin.name.replace("_", "-") in multiple places; consider centralizing this into a single normalization helper to keep the transformation consistent and easier to adjust if the naming convention changes again.
  • On the frontend, normalizeStr is used alongside the backend’s underscore-to-dash conversion; it would be safer to clearly align and document the exact normalization rules in one place (or share a utility) so that backend/ frontend name matching cannot drift over time.
  • This PR introduces new dashboard dependencies (@ricky0123/vad-web, onnxruntime-web) that don’t seem directly related to the plugin name matching fix; consider either moving these to a separate PR or clarifying why they are required for this change.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The backend now does `plugin.name.replace("_", "-")` in multiple places; consider centralizing this into a single normalization helper to keep the transformation consistent and easier to adjust if the naming convention changes again.
- On the frontend, `normalizeStr` is used alongside the backend’s underscore-to-dash conversion; it would be safer to clearly align and document the exact normalization rules in one place (or share a utility) so that backend/ frontend name matching cannot drift over time.
- This PR introduces new dashboard dependencies (`@ricky0123/vad-web`, `onnxruntime-web`) that don’t seem directly related to the plugin name matching fix; consider either moving these to a separate PR or clarifying why they are required for this change.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies plugin name handling by replacing underscores with hyphens in API responses and updates the frontend matching logic. It also introduces new dependencies and adjusts the timing of update checks. Feedback highlights that hyphenating names in the API is a breaking change for backend operations like uninstallation and updates, as the backend still expects underscores. Furthermore, the frontend matching logic is now considered fragile due to the removal of separator normalization, and the addition of the @ricky0123/vad-web and onnxruntime-web dependencies appears unrelated to the core changes.

Comment on lines +1272 to +1274
"name": plugin.name.replace(
"_", "-"
), # 统一转换为减号格式,与市场数据保持一致
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Changing the name field from underscores to hyphens in the API response is a breaking change for plugin management. This field acts as the unique identifier for plugins in subsequent API calls such as /api/plugin/uninstall, /api/plugin/on/off, and /api/plugin/update. Since the backend lookup logic (e.g., get_registered_star or _get_plugin_metadata_by_name) performs a direct string comparison against the internal plugin name (which still uses underscores), these operations will fail for any plugin containing an underscore.

Furthermore, this will break plugin pages because _serve_plugin_page_content uses this name to look up metadata. It is recommended to keep the original name as the identifier and add a separate field for marketplace matching, or update all backend lookup logic to be separator-insensitive. Additionally, refactor the lookup logic into a shared helper function and ensure this new functionality is accompanied by unit tests.

References
  1. When implementing similar functionality for different cases (e.g., direct vs. quoted attachments), refactor the logic into a shared helper function to avoid code duplication.
  2. New functionality, such as handling attachments, should be accompanied by corresponding unit tests.

Comment thread dashboard/package.json Outdated
},
"dependencies": {
"@guolao/vue-monaco-editor": "^1.5.4",
"@ricky0123/vad-web": "^0.0.30",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The addition of @ricky0123/vad-web and onnxruntime-web (line 35) appears unrelated to the PR's objective of fixing plugin name matching and update checking. These dependencies introduce significant weight to the dashboard and should be removed if they are not strictly required for this fix.

Comment on lines +645 to +656
const normalizedName = normalizeStr(plugin.name);
onlinePluginsNameMap.set(normalizedName, plugin);
});

const data = Array.isArray(extension_data?.data) ? extension_data.data : [];

data.forEach((extension) => {
const repoKey = extension.repo?.toLowerCase();
const onlinePlugin = repoKey ? onlinePluginsMap.get(repoKey) : null;
const onlinePluginByName = onlinePluginsNameMap.get(extension.name);

const normalizedExtensionName = normalizeStr(extension.name);
const onlinePluginByName = onlinePluginsNameMap.get(normalizedExtensionName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The normalizeStr function only performs lowercasing and trimming; it does not handle the _ vs - difference. While the backend now returns hyphenated names in some responses, this makes the frontend matching logic fragile and dependent on inconsistent backend behavior. To ensure robust matching regardless of the backend's internal representation, it is safer to continue normalizing separators (e.g., .replace(/_/g, '-')) during comparison. Consider refactoring this logic into a shared helper function to avoid code duplication.

References
  1. When implementing similar functionality for different cases (e.g., direct vs. quoted attachments), refactor the logic into a shared helper function to avoid code duplication.

@Waterwzy
Copy link
Copy Markdown
Contributor Author

有点问题,我得改一下

@Waterwzy Waterwzy closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature:plugin The bug / feature is about AstrBot plugin system. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant