From d879f5b67be2a0f69b96ac2b80efbd61e80d3b91 Mon Sep 17 00:00:00 2001 From: Echo Date: Thu, 19 Feb 2026 10:32:23 -0500 Subject: [PATCH] fix(mattermost): fail closed when slash channel type is unknown --- .../mattermost/src/mattermost/slash-http.ts | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/extensions/mattermost/src/mattermost/slash-http.ts b/extensions/mattermost/src/mattermost/slash-http.ts index 3428a8d18c3..7274832829c 100644 --- a/extensions/mattermost/src/mattermost/slash-http.ts +++ b/extensions/mattermost/src/mattermost/slash-http.ts @@ -140,11 +140,28 @@ async function authorizeSlashInvocation(params: { let channelInfo: MattermostChannel | null = null; try { channelInfo = await fetchMattermostChannel(client, channelId); - } catch { - // continue without channel info + } catch (err) { + log?.(`mattermost: slash channel lookup failed for ${channelId}: ${String(err)}`); } - const channelType = channelInfo?.type ?? undefined; + if (!channelInfo) { + return { + ok: false, + denyResponse: { + response_type: "ephemeral", + text: "Temporary error: unable to determine channel type. Please try again.", + }, + commandAuthorized: false, + channelInfo: null, + kind: "channel", + chatType: "channel", + channelName: "", + channelDisplay: "", + roomLabel: `#${channelId}`, + }; + } + + const channelType = channelInfo.type ?? undefined; const isDirectMessage = channelType?.toUpperCase() === "D"; const kind: SlashInvocationAuth["kind"] = isDirectMessage ? "direct"