diff --git a/src/infra/outbound/targets-loaded.test.ts b/src/infra/outbound/targets-loaded.test.ts index 87b324c8db7..be5a00def71 100644 --- a/src/infra/outbound/targets-loaded.test.ts +++ b/src/infra/outbound/targets-loaded.test.ts @@ -45,4 +45,10 @@ describe("tryResolveLoadedOutboundTarget", () => { }), ).toEqual({ ok: true, to: "123456789" }); }); + + it("trims channel ids before reading the loaded registry", () => { + tryResolveLoadedOutboundTarget({ channel: " telegram " as never, to: "123" }); + + expect(mocks.getLoadedChannelPlugin).toHaveBeenCalledWith("telegram"); + }); }); diff --git a/src/infra/outbound/targets-loaded.ts b/src/infra/outbound/targets-loaded.ts index e09b4a6b130..4f30e8668a0 100644 --- a/src/infra/outbound/targets-loaded.ts +++ b/src/infra/outbound/targets-loaded.ts @@ -2,19 +2,16 @@ import { getLoadedChannelPluginForRead } from "../../channels/plugins/registry-l import type { ChannelPlugin } from "../../channels/plugins/types.plugin.js"; import type { ChannelOutboundTargetMode } from "../../channels/plugins/types.public.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; +import { normalizeOptionalString } from "../../shared/string-coerce.js"; import type { GatewayMessageChannel } from "../../utils/message-channel.js"; -import { - isDeliverableMessageChannel, - normalizeMessageChannel, -} from "../../utils/message-channel.js"; import { resolveOutboundTargetWithPlugin, type OutboundTargetResolution, } from "./targets-resolve-shared.js"; function resolveLoadedOutboundChannelPlugin(channel: string): ChannelPlugin | undefined { - const normalized = normalizeMessageChannel(channel); - if (!normalized || !isDeliverableMessageChannel(normalized)) { + const normalized = normalizeOptionalString(channel); + if (!normalized) { return undefined; }