diff --git a/src/shared/services/apiKeyResolver.ts b/src/shared/services/apiKeyResolver.ts index 9f14926e61..5896c385c1 100644 --- a/src/shared/services/apiKeyResolver.ts +++ b/src/shared/services/apiKeyResolver.ts @@ -39,6 +39,6 @@ export async function getOrCreateApiKey(apiKeyId?: string | null): Promise { // Force XDG_CONFIG_HOME so resolveOpencodeConfigPath resolves to our dummy dir // (CI runners often have XDG_CONFIG_HOME set, causing path mismatch) process.env.XDG_CONFIG_HOME = path.join(DUMMY_HOME, ".config"); + process.env.API_KEY_SECRET = "test-secret"; await fs.mkdir(path.dirname(QWEN_CONFIG_PATH), { recursive: true }).catch(() => {}); }); diff --git a/tests/unit/qwen-api-key-auto-create.test.ts b/tests/unit/qwen-api-key-auto-create.test.ts index ba6e7ff05a..fa4f8b4816 100644 --- a/tests/unit/qwen-api-key-auto-create.test.ts +++ b/tests/unit/qwen-api-key-auto-create.test.ts @@ -26,6 +26,7 @@ const originalHomedir = os.homedir; test.beforeEach(async () => { process.env.DATA_DIR = DUMMY_HOME; + process.env.API_KEY_SECRET = "test-secret"; os.homedir = () => DUMMY_HOME; await fs.mkdir(DUMMY_HOME, { recursive: true }).catch(() => {}); // Initialize DB