From 4e4a1000382609496b68d0a155267c45e4b27365 Mon Sep 17 00:00:00 2001 From: bmendonca3 Date: Sun, 1 Mar 2026 00:59:57 -0700 Subject: [PATCH] Feishu: honor configured default account --- extensions/feishu/src/accounts.test.ts | 19 +++++++++++++++++-- extensions/feishu/src/accounts.ts | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/extensions/feishu/src/accounts.test.ts b/extensions/feishu/src/accounts.test.ts index 23afb9a174a..f32bfa12e4d 100644 --- a/extensions/feishu/src/accounts.test.ts +++ b/extensions/feishu/src/accounts.test.ts @@ -33,11 +33,26 @@ describe("resolveDefaultFeishuAccountId", () => { expect(resolveDefaultFeishuAccountId(cfg as never)).toBe("router-d"); }); - it("falls back to literal default account id when preferred is missing", () => { + it("keeps configured defaultAccount even when not present in accounts map", () => { + const cfg = { + channels: { + feishu: { + defaultAccount: "router-d", + accounts: { + default: { appId: "cli_default", appSecret: "secret_default" }, + zeta: { appId: "cli_zeta", appSecret: "secret_zeta" }, + }, + }, + }, + }; + + expect(resolveDefaultFeishuAccountId(cfg as never)).toBe("router-d"); + }); + + it("falls back to literal default account id when present", () => { const cfg = { channels: { feishu: { - defaultAccount: "missing", accounts: { default: { appId: "cli_default", appSecret: "secret_default" }, zeta: { appId: "cli_zeta", appSecret: "secret_zeta" }, diff --git a/extensions/feishu/src/accounts.ts b/extensions/feishu/src/accounts.ts index 1bf625becb3..ca7c33a4c07 100644 --- a/extensions/feishu/src/accounts.ts +++ b/extensions/feishu/src/accounts.ts @@ -37,10 +37,10 @@ export function listFeishuAccountIds(cfg: ClawdbotConfig): string[] { export function resolveDefaultFeishuAccountId(cfg: ClawdbotConfig): string { const preferredRaw = (cfg.channels?.feishu as FeishuConfig | undefined)?.defaultAccount?.trim(); const preferred = preferredRaw ? normalizeAccountId(preferredRaw) : undefined; - const ids = listFeishuAccountIds(cfg); - if (preferred && ids.includes(preferred)) { + if (preferred) { return preferred; } + const ids = listFeishuAccountIds(cfg); if (ids.includes(DEFAULT_ACCOUNT_ID)) { return DEFAULT_ACCOUNT_ID; }