You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Slack has a limit of 3000 chars on a section type. We should truncate long messages to fit because a truncated message is much better than no message and it will signal that the limit exists to the dev.
Rough example:
constbuildSlackMsg=(event: unknown): IncomingWebhookSendArguments=>{letwarning=JSON.stringify(event,undefined,2);// The maximum length of a `section.text` field in Slack API is 3000// characters (https://api.slack.com/reference/block-kit/blocks#section) Slack// Webhooks will HTTP 400 if the message we give it is too long.constTRUNCATED_TEXT_REPLACEMENT='\n\n[MESSAGE TRUNCATED FOR SLACK]';constWRAPPER_TEXT_LENGTH=12;// 6 quoted backticksconstMAX_WARNING_LENGTH=3000-WRAPPER_TEXT_LENGTH-TRUNCATED_TEXT_REPLACEMENT.length;if(warning.length>MAX_WARNING_LENGTH){warning=warning.substring(0,MAX_WARNING_LENGTH);warning=warning.concat(TRUNCATED_TEXT_REPLACEMENT);}constalarmMessage=`\`\`\`${warning}\`\`\``;return{channel: process.env.SLACK_CHANNEL,blocks: [{type: 'header',text: {type: 'plain_text',text: ':warning: An event requires investigation',emoji: true}},{type: 'section',text: {type: 'mrkdwn',text: alarmMessage}}]};};
The text was updated successfully, but these errors were encountered:
Slack has a limit of 3000 chars on a
section
type. We should truncate long messages to fit because a truncated message is much better than no message and it will signal that the limit exists to the dev.Rough example:
The text was updated successfully, but these errors were encountered: