Skip to content

Commit a4c4f08

Browse files
[AI] test(feishu): add regression for partial channelRuntime lacking inbound
When channelRuntime has runtimeContexts but no inbound, the guard in bot.ts should fall back to getFeishuRuntime().channel. Add a test that passes a partial channelRuntime and verifies dispatch does not crash. Refs #93453
1 parent f85fec6 commit a4c4f08

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

extensions/feishu/src/bot.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ async function dispatchMessage(params: {
422422
cfg: ClawdbotConfig;
423423
currentCfg?: ClawdbotConfig;
424424
event: FeishuMessageEvent;
425+
channelRuntime?: PluginRuntime["channel"];
425426
}) {
426427
const runtime = createRuntimeEnv();
427428
const feishuConfig = params.cfg.channels?.feishu;
@@ -443,6 +444,7 @@ async function dispatchMessage(params: {
443444
cfg,
444445
event: params.event,
445446
runtime,
447+
channelRuntime: params.channelRuntime,
446448
});
447449
return runtime;
448450
}
@@ -960,6 +962,30 @@ describe("handleFeishuMessage ACP routing", () => {
960962
);
961963
expect(dispatcherOptions.allowReasoningPreview).toBe(true);
962964
});
965+
966+
it("falls back to full runtime channel when partial channelRuntime lacks inbound", async () => {
967+
const partialChannelRuntime = {
968+
runtimeContexts: {} as PluginRuntime["channel"]["runtimeContexts"],
969+
} as PluginRuntime["channel"];
970+
971+
await dispatchMessage({
972+
cfg: {
973+
session: { mainKey: "main", scope: "per-sender" },
974+
channels: { feishu: { enabled: true, allowFrom: ["ou_sender_1"], dmPolicy: "open" } },
975+
},
976+
event: {
977+
sender: { sender_id: { open_id: "ou_sender_1" } },
978+
message: {
979+
message_id: "msg-partial-runtime",
980+
chat_id: "oc_dm",
981+
chat_type: "p2p",
982+
message_type: "text",
983+
content: JSON.stringify({ text: "hello" }),
984+
},
985+
},
986+
channelRuntime: partialChannelRuntime,
987+
});
988+
});
963989
});
964990

965991
describe("handleFeishuMessage command authorization", () => {

0 commit comments

Comments
 (0)