fix(mattermost): fail closed if listing slash commands fails

This commit is contained in:
Echo 2026-02-15 11:05:48 -05:00 committed by Muhammed Mukhthar CM
parent 994dcf7bdc
commit 8c64b726fd
1 changed files with 4 additions and 0 deletions

View File

@ -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]));