diff --git a/extensions/mattermost/src/mattermost/slash-commands.ts b/extensions/mattermost/src/mattermost/slash-commands.ts index 08ba8651098..252169e844b 100644 --- a/extensions/mattermost/src/mattermost/slash-commands.ts +++ b/extensions/mattermost/src/mattermost/slash-commands.ts @@ -251,6 +251,10 @@ export async function registerSlashCommands(params: { existing = await listMattermostCommands(client, teamId); } catch (err) { log?.(`mattermost: failed to list existing commands: ${String(err)}`); + // Fail closed: if we can't list existing commands, we should not attempt to + // create/update anything because we may create duplicates and end up with an + // empty/partial token set (causing callbacks to be rejected until restart). + throw err; } const existingByTrigger = new Map(existing.map((cmd) => [cmd.trigger, cmd]));