Skip to content

Commit 955cb06

Browse files
sergicalcodex
andcommitted
fix(opencode): preserve MCP config on cleanup failure
Co-Authored-By: GPT-5.6 <noreply@openai.com>
1 parent 4203ffb commit 955cb06

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

packages/installer/src/__tests__/harnesses.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,18 @@ function testOpenCodeHarness(testCase: OpenCodeHarnessCase) {
438438
expect(cleaned).toBe("Removed the incompatible Sentry OpenCode bundle and MCP configuration");
439439
});
440440

441+
it("preserves MCP configuration when incompatible bundle removal fails", async () => {
442+
const system = fakeSystem({
443+
homedir: "/home/user",
444+
existing: [target, incompatibleMarker],
445+
files: { [configPath]: testCase.configWithIncompatibleMcp },
446+
run: () => ({ ok: false, stderr: "bundle is locked" }),
447+
});
448+
449+
await expect(testCase.create(system).cleanup!()).rejects.toThrow("bundle is locked");
450+
expect(system.writeTextFile).not.toHaveBeenCalled();
451+
});
452+
441453
it("leaves its own bundle untouched during cleanup", async () => {
442454
const system = fakeSystem({ homedir: "/home/user", existing: [target, marker] });
443455
expect(await testCase.create(system).cleanup!()).toBeNull();

packages/installer/src/harnesses/opencode-common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ export function createOpenCodeHarness(
117117
cleanup: async (output) => {
118118
const incompatibleBundle = hasIncompatibleBundle();
119119
const partialBundle = system.exists(bundleDir(system)) && !hasOwnBundle();
120-
const incompatibleMcp = removeMcpConfigPaths(system, [options.incompatibleMcpConfigPath]);
121120

122121
if (incompatibleBundle || partialBundle) {
123122
await removeBundle(system, output);
124123
}
125124

125+
const incompatibleMcp = removeMcpConfigPaths(system, [options.incompatibleMcpConfigPath]);
126+
126127
if (incompatibleBundle) {
127128
return incompatibleMcp
128129
? "Removed the incompatible Sentry OpenCode bundle and MCP configuration"

0 commit comments

Comments
 (0)