Skip to content

Commit c0200f0

Browse files
committed
Refactored the way variables pass to ask_ai to get to slack channels
1 parent f82e7e5 commit c0200f0

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/robusta/core/playbooks/internal/ai_integration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ def ask_holmes(event: ExecutionBaseEvent, params: AIInvestigateParams):
115115
runner_context = getattr(params, "robusta_context", None) # Safely get the context dict
116116
if runner_context and "thread_ts" in runner_context:
117117
original_thread_ts = runner_context.get("thread_ts")
118+
original_channel_id = runner_context.get("channel_id")
118119
if original_thread_ts:
119120
finding.robusta_context["thread_ts"] = original_thread_ts
121+
finding.robusta_context["channel_id"] = original_channel_id
120122
logging.info(f"Added message_ts={original_thread_ts} to finding {finding.id} annotations.")
121123
else:
122124
logging.warning(f"message_ts found in robusta_context for finding {finding.id} but it is empty.")

src/robusta/integrations/receiver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ def __exec_external_request(self, action_request: ExternalActionRequest, validat
178178

179179
if action_request.slack_container and action_request.slack_container.message_ts:
180180
thread_ts = action_request.slack_container.message_ts
181-
action_request.body.action_params["robusta_context"] = {"thread_ts": thread_ts}
181+
channel_id = action_request.slack_container.channel_id
182+
action_request.body.action_params["robusta_context"] = {"thread_ts": thread_ts, "channel_id": channel_id}
182183

183184
response = self.event_handler.run_external_action(
184185
action_request.body.action_name,

src/robusta/integrations/slack/sender.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,16 +589,16 @@ def send_finding_to_slack(
589589
)
590590
robusta_context = getattr(finding, "robusta_context", None)
591591
effective_thread_ts = thread_ts # Default to the one passed in (e.g., from grouping)
592+
effective_channel_id = slack_channel
592593
if robusta_context:
593594
annotation_ts = robusta_context.get("thread_ts")
595+
channel_id = robusta_context.get("channel_id")
594596
if annotation_ts: # Make sure it's not None or empty
595597
effective_thread_ts = annotation_ts # Prioritize the annotation!
596-
logging.info(f"Using thread_ts from annotation for AI analysis finding {finding.id}: {effective_thread_ts}")
597-
else:
598-
logging.warning(f"Found empty message_ts annotation for AI analysis finding {finding.id}, using original thread_ts: {thread_ts}")
598+
effective_channel_id = channel_id
599599
if finding.finding_type == FindingType.AI_ANALYSIS:
600600
# holmes analysis message needs special handling
601-
self.send_holmes_analysis(finding, slack_channel, platform_enabled, effective_thread_ts)
601+
self.send_holmes_analysis(finding, effective_channel_id, platform_enabled, effective_thread_ts)
602602
return "" # [arik] Looks like the return value here is not used, needs to be removed
603603

604604
status: FindingStatus = (

0 commit comments

Comments
 (0)