Skip to content

Commit 9f27b8d

Browse files
Add send_files parameter to MS Teams sink to handle 28KB limit
Replace the incorrectly used send_svg parameter with send_files: - send_svg was designed only for SVG files (see commit e354c48) - MS Teams 28KB limit affects all file types, not just SVGs - Follow existing pattern from Telegram, Pushover, YaMessenger sinks Changes: - Add send_files: bool = True to MsTeamsSinkParams - Update sender.py to filter all files when send_files is False - Remove incorrect is_image import from sender.py - Add docstring to write_finding for CodeRabbit coverage - Update documentation with new parameter name
1 parent d50052d commit 9f27b8d

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

docs/configuration/sinks/ms-teams.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,24 @@ For example:
9595
webhook_url: teams-incoming-webhook
9696
prefer_redirect_to_platform: false
9797
98-
Disabling Images
98+
Disabling File Attachments
9999
-------------------------------------------------------------------
100100

101101
MS Teams Power Automate workflow webhooks have a strict 28KB payload size limit.
102-
Alerts with embedded graphs or images may exceed this limit.
102+
Alerts with embedded files (graphs, images, logs) may exceed this limit.
103103

104-
To disable image embedding and reduce payload size, set ``send_svg: false``:
104+
To disable file attachments and reduce payload size, set ``send_files: false``:
105105

106106
.. code-block:: yaml
107107
108108
sinksConfig:
109109
- ms_teams_sink:
110110
name: main_ms_teams_sink
111111
webhook_url: teams-incoming-webhook
112-
send_svg: false # Disables image embedding to reduce payload size
112+
send_files: false # Disables all file attachments to reduce payload size
113113
114114
.. note::
115115

116-
When ``send_svg`` is false (the default), image files such as memory graphs
116+
When ``send_files`` is false, all file attachments (images, logs, etc.)
117117
will not be included in the MS Teams message. Text-based content will still
118118
be sent normally.

src/robusta/core/sinks/msteams/msteams_sink.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ def __init__(self, sink_config: MsTeamsSinkConfigWrapper, registry):
1212
self.sink_config = sink_config.ms_teams_sink
1313

1414
def write_finding(self, finding: Finding, platform_enabled: bool):
15+
"""Write a finding to the MS Teams channel via webhook.
16+
17+
Args:
18+
finding: The finding to send to MS Teams.
19+
platform_enabled: Whether the Robusta platform is enabled for enhanced links.
20+
"""
1521
MsTeamsSender.send_finding_to_ms_teams(
1622
self.webhook_url,
1723
finding,
@@ -20,5 +26,5 @@ def write_finding(self, finding: Finding, platform_enabled: bool):
2026
self.account_id,
2127
self.webhook_override,
2228
self.sink_config.prefer_redirect_to_platform,
23-
self.sink_config.send_svg,
29+
self.sink_config.send_files,
2430
)

src/robusta/core/sinks/msteams/msteams_sink_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
class MsTeamsSinkParams(SinkBaseParams):
1111
webhook_url: str
1212
webhook_override: Optional[str] = None
13+
send_files: bool = True # Set False to disable file attachments (avoids 28KB limit)
1314

1415
@classmethod
1516
def _get_sink_type(cls):

src/robusta/integrations/msteams/sender.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
TableBlock,
1515
EmptyFileBlock,
1616
)
17-
from robusta.core.reporting.utils import is_image
1817
from robusta.core.sinks.msteams.msteams_webhook_tranformer import MsTeamsWebhookUrlTransformer
1918
from robusta.integrations.msteams.msteams_msg import MsTeamsMsg
2019

@@ -62,7 +61,7 @@ def send_finding_to_ms_teams(
6261
account_id: str,
6362
webhook_override: str,
6463
prefer_redirect_to_platform: bool,
65-
send_svg: bool = False,
64+
send_files: bool = True,
6665
):
6766
"""Send a finding to MS Teams via webhook.
6867
@@ -74,8 +73,8 @@ def send_finding_to_ms_teams(
7473
account_id: The Robusta account ID.
7574
webhook_override: Optional webhook URL override pattern.
7675
prefer_redirect_to_platform: Whether to prefer platform links over Prometheus.
77-
send_svg: Whether to include image files. When False (default), images are
78-
filtered out to avoid exceeding MS Teams payload size limits.
76+
send_files: Whether to include file attachments. When False, all files
77+
are filtered out to avoid exceeding MS Teams 28KB payload limit.
7978
"""
8079
webhook_url = MsTeamsWebhookUrlTransformer.template(
8180
webhook_override=webhook_override, default_webhook_url=webhook_url, annotations=finding.subject.annotations
@@ -86,10 +85,9 @@ def send_finding_to_ms_teams(
8685
for enrichment in finding.enrichments:
8786
files_blocks, other_blocks = cls.__split_block_to_files_and_all_the_rest(enrichment)
8887

89-
# Filter out image files when send_svg is False to avoid payload size issues
90-
# This matches behavior of other sinks (Slack, Discord, Jira, etc.)
91-
if not send_svg:
92-
files_blocks = [b for b in files_blocks if not is_image(b.filename)]
88+
# Filter out all files when send_files is False to avoid 28KB payload limit
89+
if not send_files:
90+
files_blocks = []
9391

9492
for block in other_blocks:
9593
cls.__to_ms_teams(block, msg)

0 commit comments

Comments
 (0)