diff --git a/.changeset/crazy-chefs-sin.md b/.changeset/crazy-chefs-sin.md new file mode 100644 index 0000000000..8d33add929 --- /dev/null +++ b/.changeset/crazy-chefs-sin.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-notifications-backend-module-slack': patch +--- + +Fix slack notification processor to handle a notification with an empty description diff --git a/plugins/notifications-backend-module-slack/src/lib/SlackNotificationProcessor.test.ts b/plugins/notifications-backend-module-slack/src/lib/SlackNotificationProcessor.test.ts index f5893ff456..3229c681c8 100644 --- a/plugins/notifications-backend-module-slack/src/lib/SlackNotificationProcessor.test.ts +++ b/plugins/notifications-backend-module-slack/src/lib/SlackNotificationProcessor.test.ts @@ -158,6 +158,10 @@ describe('SlackNotificationProcessor', () => { blocks: [ { type: 'section', + text: { + text: 'No description provided', + type: 'mrkdwn', + }, accessory: { type: 'button', text: { @@ -229,6 +233,10 @@ describe('SlackNotificationProcessor', () => { blocks: [ { type: 'section', + text: { + text: 'No description provided', + type: 'mrkdwn', + }, accessory: { type: 'button', text: { diff --git a/plugins/notifications-backend-module-slack/src/lib/util.ts b/plugins/notifications-backend-module-slack/src/lib/util.ts index 5e2adbeec5..2d3a03bd2c 100644 --- a/plugins/notifications-backend-module-slack/src/lib/util.ts +++ b/plugins/notifications-backend-module-slack/src/lib/util.ts @@ -46,12 +46,10 @@ export function toSlackBlockKit(payload: NotificationPayload): KnownBlock[] { return [ { type: 'section', - ...(description && { - text: { - type: 'mrkdwn', - text: description ?? 'No description provided', - }, - }), + text: { + type: 'mrkdwn', + text: description ?? 'No description provided', + }, accessory: { type: 'button', text: {