fix(regression): reject disabled channel auth stubs

This commit is contained in:
Tak Hoffman
2026-03-27 23:05:58 -05:00
parent 4e50548e46
commit fd48e4090a
2 changed files with 14 additions and 11 deletions

View File

@@ -126,19 +126,13 @@ describe("channel-auth", () => {
);
});
it("auto-picks the single auth-capable channel even when raw channel config is omitted", async () => {
mocks.loadConfig.mockReturnValue({ channels: {} });
plugin.config.listAccountIds.mockReturnValue(["default"]);
mocks.resolveAccount.mockReturnValue({ enabled: true });
it("does not auto-pick enabled-only channel stubs when channel is omitted", async () => {
mocks.loadConfig.mockReturnValue({ channels: { whatsapp: { enabled: false } } });
await runChannelLogin({}, runtime);
expect(mocks.normalizeChannelId).toHaveBeenCalledWith("whatsapp");
expect(mocks.login).toHaveBeenCalledWith(
expect.objectContaining({
channelInput: "whatsapp",
}),
await expect(runChannelLogin({}, runtime)).rejects.toThrow(
"Channel is required (no configured channels support login).",
);
expect(mocks.login).not.toHaveBeenCalled();
});
it("ignores configured channels that do not support login when channel is omitted", async () => {

View File

@@ -29,6 +29,15 @@ function isConfiguredAuthPlugin(plugin: ChannelPlugin, cfg: OpenClawConfig): boo
if (isBlockedObjectKey(key)) {
return false;
}
const channelCfg = (cfg.channels as Record<string, unknown> | undefined)?.[key];
if (
channelCfg &&
typeof channelCfg === "object" &&
"enabled" in channelCfg &&
(channelCfg as { enabled?: unknown }).enabled === false
) {
return false;
}
for (const accountId of plugin.config.listAccountIds(cfg)) {
try {