Skip to content

Conversation

@philslab-ninja
Copy link
Contributor

@philslab-ninja philslab-ninja commented Jan 14, 2026

Summary

Auto-detect Power Automate webhook URLs and disable file attachments by default to avoid the 28KB payload limit. Legacy webhook URLs keep files enabled. User configuration always overrides auto-detection.

Background

Microsoft Teams webhooks have a 28KB message size limit:

"The message size limit is 28 KB. When the size exceeds 28 KB, you receive an error."

With the retirement of Office 365 connectors, users are migrating from legacy webhooks (*.webhook.office.com) to Power Automate Workflows (*.api.powerplatform.com). Base64-encoded images in alerts frequently exceed this limit.

Changes

  • Add new send_files: Optional[bool] = None parameter to MS Teams sink
  • Add _is_power_automate_url() helper to detect Power Automate webhooks
  • Auto-disable files for Power Automate URLs (*.api.powerplatform.com)
  • Keep files enabled for legacy webhooks (*.webhook.office.com)
  • Explicit send_files: true/false always overrides auto-detection
  • Update documentation with auto-detection behavior

How it works

URL Pattern Default send_files
*.api.powerplatform.com false (auto)
*.webhook.office.com true (auto)
Any URL with explicit config Uses configured value

Test plan

  • Verify Power Automate webhooks auto-disable file attachments
  • Verify legacy webhooks keep file attachments enabled
  • Verify explicit send_files: true overrides auto-detection for Power Automate
  • Verify explicit send_files: false disables files for legacy webhooks
  • Verify text-based content is still sent when files are disabled

References

Fixes #1994

The MS Teams sink was embedding base64-encoded images in the Adaptive Card
payload, causing 'payload too large' errors with Power Automate webhooks
(which have a strict 28KB limit).

Other sinks (Slack, Discord, Jira, Zulip, etc.) already check the send_svg
parameter to filter out images, but MS Teams was missing this check.

Changes:
- Pass send_svg parameter from MsTeamsSink to MsTeamsSender
- Filter image FileBlocks when send_svg=False using is_image() helper
- Add documentation for the send_svg setting

Fixes robusta-dev#1994
@CLAassistant
Copy link

CLAassistant commented Jan 14, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link

coderabbitai bot commented Jan 14, 2026

Walkthrough

Adds an optional send_files sink parameter (with auto-detection for Power Automate URLs), forwards it from MsTeams sink into the sender, and conditionally excludes file attachments when send_files is false; documentation updated with a "File Attachments" subsection and YAML examples.

Changes

Cohort / File(s) Summary
Documentation
docs/configuration/sinks/ms-teams.rst
Adds "File Attachments" subsection describing auto-detection of Power Automate URLs, the send_files override, YAML examples, and notes that text remains sent and prefer_redirect_to_platform unchanged.
Sink params & forwarding
src/robusta/core/sinks/msteams/msteams_sink_params.py, src/robusta/core/sinks/msteams/msteams_sink.py
Adds send_files: Optional[bool] = None to MsTeamsSinkParams and forwards sink_config.send_files into MsTeamsSender.send_finding_to_ms_teams.
Sender logic
src/robusta/integrations/msteams/sender.py
Adds _is_power_automate_url helper and send_files: Optional[bool]=None parameter to MsTeamsSender.send_finding_to_ms_teams; auto-detects default (disable for Power Automate), and filters out FileBlock attachments when send_files is false before sending.

Sequence Diagram(s)

sequenceDiagram
    participant Config as Sink Config
    participant Sink as MsTeamsSink
    participant Sender as MsTeamsSender
    participant Teams as MS Teams Webhook

    Config->>Sink: sink_config (webhook_url, send_files?)
    Sink->>Sender: send_finding_to_ms_teams(..., send_files=cfg.send_files)
    Sender->>Sender: if send_files is None -> _is_power_automate_url(webhook_url) -> decide send_files
    Sender->>Sender: split blocks into files_blocks and other_blocks
    alt send_files is false
        Sender-->>Sender: drop files_blocks
    else send_files is true
        Sender->>Sender: upload files_blocks as attachments
    end
    Sender->>Teams: send Adaptive Card (with/without attachments)
    Teams-->>Sender: response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: auto-detecting Power Automate URLs and disabling file attachments by default.
Linked Issues check ✅ Passed The PR implements all requirements from issue #1994: adds send_files parameter, implements auto-detection for Power Automate URLs, filters FileBlocks when disabled, and updates documentation.
Out of Scope Changes check ✅ Passed All changes are within scope of issue #1994: parameter addition, auto-detection logic, file filtering, and documentation updates directly address the 28KB payload limit problem.
Description check ✅ Passed The PR description clearly relates to the changeset, explaining auto-detection of Power Automate URLs to disable file attachments and the new send_files parameter.

✏️ 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

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.

@philslab-ninja philslab-ninja marked this pull request as draft January 14, 2026 17:05
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
@philslab-ninja philslab-ninja changed the title Fix MS Teams sink to respect send_svg parameter Add send_files parameter to MS Teams sink to handle 28KB payload limit Jan 14, 2026
- Change send_files from bool to Optional[bool] with None default
- Add _is_power_automate_url() helper to detect Power Automate webhooks
- Auto-disable files for Power Automate URLs (*.api.powerplatform.com)
- Keep files enabled for legacy webhooks (*.webhook.office.com)
- Explicit send_files: true/false always overrides auto-detection
- Update documentation with auto-detection behavior
@philslab-ninja philslab-ninja force-pushed the fix/msteams-send-svg-parameter branch from befa7f8 to ed438ac Compare January 14, 2026 17:33
@philslab-ninja philslab-ninja changed the title Add send_files parameter to MS Teams sink to handle 28KB payload limit MS Teams: Auto-detect Power Automate and disable file attachments Jan 14, 2026
@philslab-ninja philslab-ninja marked this pull request as ready for review January 14, 2026 17:38
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/robusta/integrations/msteams/sender.py`:
- Around line 22-28: Docstring for _is_power_automate_url is misleading about
legacy domains; update the docstring to remove the incorrect reference to
'*.webhook.office.com' and either omit legacy domain mention or replace it with
the correct retiring domain '*.logic.azure.com' (or state that legacy connectors
are retired) so the description matches the implemented detection (checks for
".api.powerplatform.com" and "/powerautomate/"); keep the function name
_is_power_automate_url and its behavior unchanged.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between befa7f8 and ed438ac.

📒 Files selected for processing (3)
  • docs/configuration/sinks/ms-teams.rst
  • src/robusta/core/sinks/msteams/msteams_sink_params.py
  • src/robusta/integrations/msteams/sender.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/configuration/sinks/ms-teams.rst
🧰 Additional context used
🧬 Code graph analysis (1)
src/robusta/integrations/msteams/sender.py (2)
src/robusta/core/sinks/msteams/msteams_webhook_tranformer.py (2)
  • MsTeamsWebhookUrlTransformer (28-69)
  • template (53-69)
src/robusta/integrations/msteams/msteams_msg.py (1)
  • MsTeamsMsg (28-198)
🔇 Additional comments (4)
src/robusta/integrations/msteams/sender.py (3)

64-89: Excellent documentation for the new parameter.

The docstring clearly explains the tri-state behavior of send_files: auto-detection when None, explicit control when True/False. Adding the parameter at the end with a default value maintains backward compatibility.


93-96: Auto-detection correctly uses the transformed webhook URL.

The auto-detection happens after MsTeamsWebhookUrlTransformer.template() is called, ensuring it evaluates the final URL (which may differ from the original due to webhook_override). This is the correct placement.


101-112: Clean filtering approach with minimal code change.

The implementation correctly filters FileBlock entries by clearing files_blocks when send_files is False. This preserves the existing code path while preventing file attachments from being included in the Adaptive Card payload.

src/robusta/core/sinks/msteams/msteams_sink_params.py (1)

13-13: Correct the claim about established pattern consistency.

The send_files: Optional[bool] = None implementation does NOT follow the established pattern from other sinks. Telegram, Pushover, and YaMessenger all use send_files: bool = True (simple boolean with default True), while MsTeams introduces a unique tri-state approach with None for auto-detection. This is a departure from the existing pattern, not a consistent implementation.

The tri-state behavior itself is sound—None enables auto-detection, True forces file sending, False disables it—but the justification in the original review is incorrect.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@philslab-ninja
Copy link
Contributor Author

philslab-ninja commented Jan 15, 2026

I created an image with the changes and tested it.

All scenarios work as expected.

  1. Autodetection is working correctly ✅

When using power automate no images are sent:
CleanShot 2026-01-15 at 12 57 55@2x

When using legacy Office365 connector images and logs are sent:
CleanShot 2026-01-15 at 12 57 18@2x

  1. Override is working correctly ✅

When setting send_files: false for the legacy URL no images or logs are sent:
CleanShot 2026-01-15 at 13 01 15@2x

When setting send_files: true for power automate URL we get an error, as expected:
CleanShot 2026-01-15 at 13 05 30@2x

Copy link
Contributor

@arikalon1 arikalon1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @philslab-ninja

@arikalon1 arikalon1 enabled auto-merge (squash) January 16, 2026 07:55
@arikalon1 arikalon1 merged commit 1fc166c into robusta-dev:master Jan 16, 2026
5 checks passed
@philslab-ninja philslab-ninja deleted the fix/msteams-send-svg-parameter branch January 16, 2026 08:03
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.

MS Teams sink needs send_files parameter to handle 28KB payload limit

3 participants