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

Open
#2,364 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
desktop

Research direction

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.

Written by the indexing model from the issue text.

Description

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,确认没有重复建议。
Dominant language
TypeScript
Stars
1.8k
Forks
151
Avg merge
3h 48m
Merged PRs (30d)
571

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 1lck/Lithe-IDEA

All issues in 1lck/Lithe-IDEA

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.