From e71c34acb2c438741d8e81be3241e2fcf2dffeea Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 12 Apr 2026 02:27:56 +0900 Subject: [PATCH] fix(migration): return true when canonical config write succeeds regardless of archive status (#3133) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously returned archivedLegacyConfig which was false when archive rename failed, even though the canonical file was successfully written. Archive failure is secondary cleanup and should not be reported as migration failure. 🤖 Generated with OhMyOpenCode assistance https://github.com/code-yeongyu/oh-my-opencode --- src/shared/migrate-legacy-config-file.test.ts | 24 ++++++++++++++++++- src/shared/migrate-legacy-config-file.ts | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/shared/migrate-legacy-config-file.test.ts b/src/shared/migrate-legacy-config-file.test.ts index 7fd8a1d7a..0277b11bc 100644 --- a/src/shared/migrate-legacy-config-file.test.ts +++ b/src/shared/migrate-legacy-config-file.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, describe, expect, it } from "bun:test" +import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test" import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs" import { tmpdir } from "node:os" import { join } from "node:path" @@ -87,4 +87,26 @@ describe("migrateLegacyConfigFile", () => { }) }) }) + + describe("#given canonical write succeeds but archive fails", () => { + describe("#when migrating the config file", () => { + it("#then returns true", () => { + const legacyPath = join(testDir, "oh-my-opencode.jsonc") + const backupPath = `${legacyPath}.bak` + const canonicalPath = join(testDir, "oh-my-openagent.jsonc") + writeFileSync(legacyPath, '{ "agents": {} }') + + // given: create backup path as directory (blocks rename, causing archive to return false) + mkdirSync(backupPath) + + // when: migrate the config file + const result = migrateLegacyConfigFile(legacyPath) + + // then: migration should return true (canonical write succeeded, archive is optional) + expect(result).toBe(true) + // then: canonical file should exist + expect(existsSync(canonicalPath)).toBe(true) + }) + }) + }) }) diff --git a/src/shared/migrate-legacy-config-file.ts b/src/shared/migrate-legacy-config-file.ts index 03c0c6241..2affcab54 100644 --- a/src/shared/migrate-legacy-config-file.ts +++ b/src/shared/migrate-legacy-config-file.ts @@ -58,7 +58,7 @@ export function migrateLegacyConfigFile(legacyPath: string): boolean { to: canonicalPath, archivedLegacyConfig, }) - return archivedLegacyConfig + return true } catch (error) { log("[migrateLegacyConfigFile] Failed to migrate legacy config file", { legacyPath, error }) return false