From 7d088f198f071e54aa70b52dfa73a7b7fd825746 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 22 Apr 2026 12:23:47 -0700 Subject: [PATCH] fix(hooks): fail open without thread ownership routing --- extensions/thread-ownership/index.test.ts | 10 ++++++++++ extensions/thread-ownership/index.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/extensions/thread-ownership/index.test.ts b/extensions/thread-ownership/index.test.ts index 49346e114d1..b195c9e9581 100644 --- a/extensions/thread-ownership/index.test.ts +++ b/extensions/thread-ownership/index.test.ts @@ -71,6 +71,16 @@ describe("thread-ownership plugin", () => { expect(globalThis.fetch).not.toHaveBeenCalled(); }); + it("fails open when Slack thread routing has no canonical conversation id", async () => { + const result = await hooks.message_sending( + { content: "hello", replyToId: "1234.5678", metadata: {}, to: "" }, + { channelId: "slack", conversationId: "" }, + ); + + expect(result).toBeUndefined(); + expect(globalThis.fetch).not.toHaveBeenCalled(); + }); + it("claims ownership successfully", async () => { vi.mocked(globalThis.fetch).mockResolvedValue( new Response(JSON.stringify({ owner: "test-agent" }), { status: 200 }), diff --git a/extensions/thread-ownership/index.ts b/extensions/thread-ownership/index.ts index bb9197fa548..03739a1c5c2 100644 --- a/extensions/thread-ownership/index.ts +++ b/extensions/thread-ownership/index.ts @@ -112,7 +112,7 @@ export default definePluginEntry({ normalizeOptionalString(event.metadata?.channelId) || normalizeOptionalString(event.to) || ""; - if (!threadTs) { + if (!threadTs || !channelId) { return undefined; } if (abTestChannels.size > 0 && !abTestChannels.has(channelId)) {