Skip to content

Commit 05324b8

Browse files
arikalon1claudeAvi-Robusta
authored
Fix channel_override not working with grouped Slack messages (#2030)
When channel_override uses labels/annotations (e.g. robusta-clusterrel-labels.severity), grouped messages were broken in two ways: 1. The group key only used group_by attributes (e.g. cluster), so findings destined for different channels (sev1, sev2, sev3) were incorrectly merged into a single group. 2. The summary message resolved the channel with empty labels/annotations, falling back to the default channel instead of the override channel. Thread replies then went to a different channel than the summary, breaking threading. Fix: resolve the channel per-finding and include it in the group key when channel_override is configured, and pass the pre-resolved channel to the summary message sender. https://claude.ai/code/session_01L3rB5LufiC9W9hGDgYMTXP Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Avi <97387909+Avi-Robusta@users.noreply.github.com>
1 parent bf02470 commit 05324b8

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

src/robusta/core/sinks/slack/slack_sink.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from robusta.core.model.env_vars import ROBUSTA_UI_DOMAIN
44
from robusta.core.reporting.base import Finding, FindingStatus
5+
from robusta.core.sinks.common.channel_transformer import ChannelTransformer
56
from robusta.core.sinks.sink_base import NotificationGroup, NotificationSummary, SinkBase
67
from robusta.core.sinks.slack.slack_sink_params import SlackSinkConfigWrapper, SlackSinkParams
78
from robusta.integrations import slack as slack_module
@@ -47,10 +48,26 @@ def handle_notification_grouping(self, finding: Finding, platform_enabled: bool)
4748
finding_data["cluster"] = self.cluster_name
4849
resolved = finding.title.startswith("[RESOLVED]")
4950

51+
# Resolve the channel for this finding so we can include it in the group key.
52+
# This ensures findings routed to different channels (via channel_override with
53+
# labels/annotations) are grouped separately per channel.
54+
resolved_channel = ChannelTransformer.template(
55+
self.params.channel_override,
56+
self.params.slack_channel,
57+
self.cluster_name,
58+
finding.subject.labels,
59+
finding.subject.annotations,
60+
)
61+
5062
# 1. Notification accounting
5163
group_key, group_header = self.get_group_key_and_header(
5264
finding_data, self.params.grouping.group_by
5365
)
66+
# Include the resolved channel in the group key so that findings destined
67+
# for different channels (e.g. due to label-based channel_override) get
68+
# separate groups, summary messages, and threads.
69+
if self.params.channel_override:
70+
group_key = group_key + (resolved_channel,)
5471

5572
if self.grouping_summary_mode:
5673
summary_key, _ = self.get_group_key_and_header(
@@ -71,6 +88,7 @@ def handle_notification_grouping(self, finding: Finding, platform_enabled: bool)
7188
msg_ts=notification_summary.message_id,
7289
investigate_uri=investigate_uri,
7390
grouping_interval=self.params.grouping.interval,
91+
channel=resolved_channel,
7492
)
7593
notification_summary.message_id = slack_thread_ts
7694
should_send_notification = self.params.grouping.notification_mode.summary.threaded

src/robusta/integrations/slack/sender.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ def send_or_update_summary_message(
861861
msg_ts: str = None, # message identifier (for updates)
862862
investigate_uri: str = None,
863863
grouping_interval: int = None, # in seconds
864+
channel: str = None, # pre-resolved channel (when channel_override uses labels/annotations)
864865
):
865866
"""Create or update a summary message with tabular information about the amount of events
866867
fired/resolved and a header describing the event group that this information concerns."""
@@ -927,14 +928,15 @@ def send_or_update_summary_message(
927928
for block in blocks:
928929
output_blocks.extend(self.__to_slack(block, sink_params.name))
929930

930-
# For grouped notifications, channel override is supported only with the `cluster` attribute
931-
channel = ChannelTransformer.template(
932-
sink_params.channel_override,
933-
sink_params.slack_channel,
934-
self.cluster_name,
935-
{},
936-
{},
937-
)
931+
if not channel:
932+
# Fallback: resolve channel without labels/annotations (only cluster_name will work)
933+
channel = ChannelTransformer.template(
934+
sink_params.channel_override,
935+
sink_params.slack_channel,
936+
self.cluster_name,
937+
{},
938+
{},
939+
)
938940
if msg_ts is not None:
939941
method = self.slack_client.chat_update
940942
kwargs = {"ts": msg_ts}

0 commit comments

Comments
 (0)