Skip to content

fix(notification): send playbook slack blocks as raw content#2786

Merged
moshloop merged 2 commits intomainfrom
fix/playbook-notification-raw-slack
Feb 11, 2026
Merged

fix(notification): send playbook slack blocks as raw content#2786
moshloop merged 2 commits intomainfrom
fix/playbook-notification-raw-slack

Conversation

@adityathebe
Copy link
Member

@adityathebe adityathebe commented Feb 10, 2026

Route playbook notification actions through SendRawNotification instead of
SendNotification so preformatted Slack blocks are not re-formatted.

Also harden Slack block detection by validating JSON structure rather
than checking for a string substring.

Summary by CodeRabbit

  • Improvements
    • Enhanced Slack notification message detection to better handle advanced block-formatted messages, ensuring consistent and reliable rendering across all notifications
    • Updated Slack notification endpoint configuration to use a fixed connection address, providing improved stability and reliability
    • Improved notification message processing architecture to better support advanced formatting options and enhanced message delivery capabilities

Route playbook notification actions through SendRawNotification instead of
SendNotification so preformatted Slack blocks are not re-formatted.

Also harden Slack block detection by validating JSON structure rather
than checking for a string substring.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

Walkthrough

Updates Slack notification handling by introducing JSON-based blocks detection to replace substring checks, refactors notification payload data structures from NotificationMessagePayload to NotificationTemplate, and switches notification sending to use raw format with conditional Slack block handling based on detected JSON structure.

Changes

Cohort / File(s) Summary
Slack Notification Logic
notification/slack.go
Added IsSlackBlocksJSON() helper function to detect JSON objects with top-level blocks arrays, replacing direct string containment checks for determining Slack message format handling.
Notification Action Processing
playbook/actions/notification.go
Refactored from NotificationMessagePayload to NotificationTemplate data structure; switched to SendRawNotification; updated Slack-specific handling to conditionally use raw blocks JSON or formatted messages based on JSON structure detection.
Configuration Fixture
fixtures/playbooks/ai-recommend-playbook.yaml
Updated Slack notification connection from templated value to fixed endpoint connection://mc/flanksource-slack.

Possibly related PRs

Suggested reviewers

  • moshloop
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: routing playbook Slack notifications through SendRawNotification to preserve preformatted Slack blocks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/playbook-notification-raw-slack

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
playbook/actions/notification.go (1)

38-51: Silent error swallowing when formatting Slack output.

On Line 47, if FormatNotificationMessage returns an error, it is silently ignored and output.Slack remains empty. This means the caller receives an empty Slack field with no indication that formatting failed. If this is intentional (best-effort for output metadata), consider at least logging the error for debuggability.

💡 Suggested improvement
-			if slackMsg, err := notification.FormatNotificationMessage(payload, "slack"); err == nil {
+			if slackMsg, err := notification.FormatNotificationMessage(payload, "slack"); err != nil {
+				ctx.Logger.V(2).Infof("failed to format slack output: %v", err)
+			} else {
 				output.Slack = slackMsg
 			}

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@moshloop moshloop merged commit 168857a into main Feb 11, 2026
9 checks passed
@moshloop moshloop deleted the fix/playbook-notification-raw-slack branch February 11, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants