fix(hooks): fail open without thread ownership routing

This commit is contained in:
Vincent Koc
2026-04-22 12:23:47 -07:00
parent e6a9e9a700
commit 7d088f198f
2 changed files with 11 additions and 1 deletions

View File

@@ -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 }),

View File

@@ -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)) {