[Feature] 清理 installedPluginFacts 的无界清单元读取与 contextsChanged/syncFunctionRelay 的静默丢错

未关闭
#2,364 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
go
领域
desktop

调研方向

Start by reading installedPluginFacts in desktop/internal/workbench/plugins.go and the three call sites (plugins.go, memory_monitor.go, plugin_displace.go), then compare with the bounded-read path via pluginpkg.ManifestFile, pluginservice.MaxManifestBytes and pluginservice.ReadInstalled. Next read contextsChanged and syncFunctionRelay in desktop/internal/pluginservice/activation.go where the errors are dropped. Done means the manifest read is bounded and shared, approval/read/parse failures surface as structured diagnostics without changing the listed entries, and tests cover corrupt manifests and relay sync failure.

由索引模型根据 Issue 内容生成。

描述

area:extensions enhancement P2 platform:cross-platform refactor review: high
Problem to solve / 要解决的问题

审查 PR #2339 涉及的文件及其紧邻上下文时,核实到两处既有债务(均早于 #2339 存在):

  1. desktop/internal/workbench/plugins.go 中 installedPluginFacts(约第 579–584 行):
    • 对每个 entry 直接 os.ReadFile(filepath.Join(entry.Installed.Path, "plugin.json")),未使用 pluginpkg.ManifestFile 与有界读取上限(pluginservice.MaxManifestBytes),也未共享版本选择/读取快照;
    • approvals.Approval(...)、os.ReadFile(...) 和 json.Unmarshal(...) 的错误均被静默吞掉,没有任何日志或错误回传(三个调用点:workbench/plugins.go、workbench/memory_monitor.go、workbench/plugin_displace.go,经 rg -n 'installedPluginFacts|"plugin\.json"' desktop/internal 核实为 workbench 唯一非测试的 "plugin.json" 直读处)。
  2. desktop/internal/pluginservice/activation.go 中:
    • contextsChanged()(第 159 行)使用 _ = s.SyncFunctionRelay(ctx, entries) 丢弃错误;
    • syncFunctionRelay()(json.Unmarshal 失败分支)直接 continue 静默跳过损坏清单而不汇总错误。

保留它的代价:

  • 安装包异常超大或权限/损坏导致的失败无法在统一日志或诊断中定位;
  • 插件上下文变化刷新 cross-plugin function relay 失败时静默退化为旧状态。
Proposed solution / 建议方案
  1. 让 installedPluginFacts 复用 pluginpkg.ManifestFile 与有界读取(或接入 pluginservice.ReadInstalled / 统一的只读清单摘要入口),并对审批记录查询、读取及 JSON 解析失败记录结构化诊断或汇总降级原因(保留现有“列表仍展示条目 ID/版本/路径”的产品语义)。
  2. 为 pluginservice/activation.go::contextsChanged 增加对非取消错误的显式结构化日志/错误回调接线,并评估 syncFunctionRelay 是否应随 partial-error 语义向上汇总损坏清单错误;同步在测试中覆盖损坏清单与 relay 同步失败路径。
  3. 风险:contextsChanged 来自上下文观察者回调,需避免刷新失败造成界面报错风暴或锁重入。
Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

Extensions / 扩展

Priority / 优先级

P2 / 后续考虑:目前不着急,可安排到后续版本

Alternatives considered / 已考虑的替代方案

保持现状继续忽略错误会导致故障静默吞没;而在修复重读快照的 PR(#2339)中顺带改动 installedPluginFacts 和观察者错误处理语义会扩大行为变更范围并影响既有调用方预期,因此按既有债务单独建单。

Additional context / 补充信息

在评审并验证 PR #2339(关联 #2058)期间核查相关文件时发现;不涉及新增用户可见能力。

Checklist / 提交前检查
  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
主要语言
TypeScript
星标
1.8k
派生
151
平均合并
3 小时 48 分钟
30 天内合并 PR
571

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

1lck/Lithe-IDEA 的其他 Issue

查看 1lck/Lithe-IDEA 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。