fix slack notification processor attachment blocks

A `section` block requires that either a `text` or `fields` item be
included. Since we were already defaulting the payload.description, this
change simply ensures that the text portion of the block is specified
(with tests updated accordingly).

Signed-off-by: Brian Phillips <28457+brianphillips@users.noreply.github.com>
This commit is contained in:
Brian Phillips
2025-04-25 13:16:51 -05:00
parent dce2bfad8c
commit 4f10768973
3 changed files with 17 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-notifications-backend-module-slack': patch
---
Fix slack notification processor to handle a notification with an empty description
@@ -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: {
@@ -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: {