fix(plugin): 修复开放插件 v4 版本与来源持久化 - #805
Conversation
There was a problem hiding this comment.
审查总结
本 PR 为开放插件系统引入了 wrapper_version、plugin_source、plugin_code 等字段的全链路持久化,从 meta schema 校验到前端节点配置保存/回显均有覆盖。整体思路清晰,向后兼容处理(旧节点 fallback)合理,测试覆盖充分。
主要建议:
- 后端错误处理应使用项目自定义异常类而非泛化的
ValueError - 测试文件的
# -*- coding: utf-8 -*-文件头不应被删除 - 前端硬编码的
'v4.0.0'fallback 建议抽为常量
无 Critical 级别问题。
| ) | ||
| return list_result.json_resp.get("data", {}).get("apis", []) | ||
| if not list_result.result: | ||
| raise ValueError("开放插件目录请求失败: {}".format(list_result.message)) |
There was a problem hiding this comment.
APIRequestError 替代 ValueError,便于上层调用(如 celery 定时同步任务)做分类处理和结构化日志。
| if not list_result.result: | ||
| raise ValueError("开放插件目录请求失败: {}".format(list_result.message)) | ||
| if not isinstance(list_result.json_resp, dict): | ||
| raise ValueError("开放插件目录响应不是合法 JSON") |
There was a problem hiding this comment.
APIResponseError 更贴切——请求成功但响应格式异常。
| @@ -1,4 +1,3 @@ | |||
| # -*- coding: utf-8 -*- | |||
| """ | |||
There was a problem hiding this comment.
✨ # -*- coding: utf-8 -*- 文件头被移除了,项目其他文件仍保留此声明,建议恢复以保持一致。
| ? savedPluginVersion || latestVersion || defaultVersion | ||
| : component.version || 'v2.0.0'; | ||
| // 兼容旧版页面曾把业务版本误存到 component.version 的节点。 | ||
| const wrapperVersion = savedWrapperVersion || (isOpenPlugin ? 'v4.0.0' : component.version || 'v2.0.0'); |
There was a problem hiding this comment.
✨ 'v4.0.0' 硬编码 fallback 建议抽为文件顶部常量(如 DEFAULT_OPEN_PLUGIN_WRAPPER_VERSION),与后端 WRAPPER_VERSION 保持语义对齐。
| await this.loadAtomConfig({ atom: plugin, version: apiVersion, space_id: this.spaceId }); | ||
| // component.version 保存 uniform_api 包装器版本,业务版本独立保存在隐藏字段中。 | ||
| const wrapperVersion = resp.data.wrapper_version || resp.data.version || 'v2.0.0'; | ||
| await this.loadAtomConfig({ atom: plugin, version: wrapperVersion, space_id: this.spaceId }); |
There was a problem hiding this comment.
✨ storeOutputs 加了 || [] fallback 很好,避免了 wrapperVersion 不在 pluginOutput 中时的 undefined 报错。
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #805 +/- ##
===========================================
- Coverage 83.28% 83.26% -0.02%
===========================================
Files 319 320 +1
Lines 20114 20143 +29
===========================================
+ Hits 16751 16773 +22
- Misses 3363 3370 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
增量审查总结
第二次提交引入了 source_key 配置项的完整支持——展示配置与执行来源分层,目录同步按有效 source_key 聚合后刷新。实现清晰,测试覆盖充分,文档同步及时。
之前的评论状态
之前报告的问题(ValueError → 自定义异常、coding: utf-8 文件头、前端 'v4.0.0' 硬编码)在本次提交中未修改,仍然建议处理。
新代码审查结论
本次增量无新的 Critical/Important 级别问题。新增的 _effective_source_key 方法兼容 dict 和 Pydantic model 两种配置格式,sync_space_plugins 的 id-based 聚合逻辑正确避免了多入口互相标记下架的问题。前端 crtSourceKey 计算属性和 apiTabList 的 sourceKey 传递链路完整。
|
相关提交已按分支规范迁移并推送至 feat/sops-open-plugin-backend(PR #698)。develop 仅作为联调目标,本 PR 不再单独合入。 |
变更内容
component.version的 wrapper 版本与子插件业务版本,不再给业务版本自动添加vuniform_api_plugin_id/uniform_api_plugin_source_key,兼容并可修复此前误存业务版本的 v4 节点uniform_api配置新增可选source_key,允许多个展示api_key共享同一个准入与执行来源source_key聚合后一次性刷新,避免两个入口互相将插件标记下架api_key展示与查询,按真实source_key保存和执行验证
pytest tests/interface/space/test_space_config.py tests/interface/plugin/services/test_open_plugin_catalog.py tests/interface/plugin/services/test_open_plugin_grant.py tests/interface/plugin/services/test_open_plugin_snapshot.py -v --no-cov@blueking/bkflow-canvas-editor-vue2未完成,报错位于未改动的TaskOperation.vue--story=133649781