Repository navigation
fix(plugin-install): guard non-object mcp/mcpServers in plugin install/remove/status (#836, #839) - #837
Conversation
…status (#836) opencode.json may carry a non-object `mcp` (e.g. a bare string); `"bili" in <non-object>` throws TypeError. remove had no guard and crashed, stranding a half-install (broken reversibility); status surfaced "error:". Guard all three sites with isPlainMcpObject: install skips a present non-object mcp, while remove/status degrade to "not installed" so remove always completes cleanly. Found hands-on testing #824 (reported in #809 as finding N4). An equivalent guard also ships inside #824; this PR lands it independently on master, which was still exposed today. Regression test added in tests/plugin-agent.test.ts. Full suite green: 1650 tests / 1648 pass / 0 fail / 2 pre-existing skip. typecheck + build clean.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-837Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr837.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Reviewing this PR now: pulled branch |
…ove (#839) Found while reviewing #837: claudeStatus() applied an unguarded 'in' operator to mcpServers from .claude.json — a non-object value crashed pluginRemove('claude') (which calls status first) and surfaced 'error:' rows from pluginStatusAll(), the same broken-reversibility shape as #836 but on the claude side. Reuse the isPlainMcpObject helper introduced by this PR; add a regression test mirroring the opencode one.
Review complete — verified, plus one addition made directly on the branch. Details below. Verified (original scope, @0c7f570)
Review addition: claude side of the same bug class → #839While sweeping the rest of Per review practice I fixed it directly on this branch rather than ping-ponging:
CIAll 7 checks green on head Conclusion: original fix is correct and complete for #836, the branch now also closes #839, CI green — ready for you to merge whenever. 中文摘要:审查确认了 opencode 非对象 mcp 的修复(master 上复现了崩溃、分支上验证了降级行为,diff 干净、无重复);review 中发现 claude 侧存在同类未防护的 mcpServers 崩溃(remove/status),已按规范先开 #839 再直接在 PR 分支补上守卫与回归测试(commit 4f9b40c),全套测试与 CI 均绿,可以合并。 |
|
继续 |
What & why
opencode.jsonmay carry a non-objectmcp(e.g. a bare string)."bili" in <non-object>throwsTypeError, which on master:bili plugin remove(opencode) — stranding a half-install (installed plugin dir + compaction edits) that could not clean itself up → broken reversibility;error:frombili plugin status;install.Guard all three opencode sites with a new
isPlainMcpObjecthelper:mcp→ skip writingmcp.bili(config left untouched, no crash);mcp→ degrade tonot installed(no crash); remove always completes cleanly, restoring reversibility.Reproduction (pre-fix, master)
Relation to #824 / #809
Found hands-on testing #824; reported in #809 as finding N4. An equivalent guard (
isPlainMcpObject) also ships inside PR #824 (commit54f8fb2). However #824 is open, unmerged, and based onfeat/pi-native-plugin, so master was still exposed today. This PR lands the guard independently on master as a minimal, focused change so it can ship without waiting on the larger feature PR.Pre-flight
npm run typecheck— cleannpm test— 1650 tests / 1648 pass / 0 fail / 2 pre-existing skipnpm run build— successRegression test added in
tests/plugin-agent.test.ts("plugin opencode survives a non-object mcp").Fixes #836 · found in #809 · related #824
Review addition (2026-09-16): claude side of the same bug class — #839
Reviewing this PR surfaced that
claudeStatus()(src/plugin-install.ts) had the unguarded\"bili\" in data.mcpServers— a non-objectmcpServersin.claude.jsoncrashedbili plugin remove claude(remove calls status first, so a half-install could not clean itself up) and surfacederror:rows frombili plugin status. Same shape as #836, claude side. Tracked as #839; fixed by a follow-up commit on this branch reusingisPlainMcpObject, plus a regression test ("plugin claude survives a non-object mcpServers").Updated pre-flight at 4f9b40c: typecheck clean; tests 1651 total / 1649 pass / 0 fail / 2 pre-existing skip; build success.