Skip to content

fix(msteams): treat HTTP 202 from Power Automate webhooks as success#2113

Open
philslab-ninja wants to merge 1 commit into
robusta-dev:masterfrom
philslab-ninja:fix/msteams-202-accepted-log-noise
Open

fix(msteams): treat HTTP 202 from Power Automate webhooks as success#2113
philslab-ninja wants to merge 1 commit into
robusta-dev:masterfrom
philslab-ninja:fix/msteams-202-accepted-log-noise

Conversation

@philslab-ninja

Copy link
Copy Markdown
Contributor

Problem

When using an MS Teams Power Automate ("Workflows") webhook, every
successfully delivered notification is logged as an error:

ERROR    Error sending to ms teams json: {...} error: Accepted

The message does arrive in the channel — this is pure log noise, but it's
alarming and makes it look like Teams notifications are failing. Reported in
#1893 and independently confirmed there on 0.31.5 / 0.32.0.

Root cause

Power Automate workflow webhooks accept the payload asynchronously and return
HTTP 202 Accepted on success, whereas the legacy Office 365 connectors
returned 200. MsTeamsMsg.send() only treated 200/201 as success:

if response.status_code not in [200, 201]:
    logging.error(f"Error sending to ms teams json: {complete_card_map} error: {response.reason}")

response.reason for a 202 is the string "Accepted" — exactly the text seen
in the logs. So a 202 falls through to the error branch even though delivery
succeeded.

Fix

Add 202 to the accepted status codes.

Testing

Added tests/test_ms_teams_send.py, parametrized over status codes:

  • 200, 201, 202 → no error logged
  • 400, 500 → error still logged (genuine failures are unaffected)

All existing MS Teams tests continue to pass.

Closes #1893

Power Automate workflow webhooks accept the payload asynchronously and
return 202 Accepted on success, while legacy Office 365 connectors return
200. send() only accepted 200/201, so every successfully delivered
notification via a Power Automate webhook was logged as
"Error sending to ms teams ... error: Accepted" even though the message
arrived in the channel.

Add 202 to the accepted status codes and a test covering send() status
code handling.

Refs robusta-dev#1893
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a27be10b-b1a8-4a34-a50c-ba0a27473acf

📥 Commits

Reviewing files that changed from the base of the PR and between 349f194 and 19badcd.

📒 Files selected for processing (2)
  • src/robusta/integrations/msteams/msteams_msg.py
  • tests/test_ms_teams_send.py

Walkthrough

MsTeamsMsg.send() now accepts HTTP 202 as a success status code alongside 200 and 201, reflecting asynchronous acceptance by Power Automate webhooks. A new test module verifies logging behavior for success and error status codes.

Changes

MS Teams Webhook Status Handling

Layer / File(s) Summary
Widen accepted status codes
src/robusta/integrations/msteams/msteams_msg.py
The success check in send() now accepts 200, 201, and 202, with comments clarifying that 202 indicates asynchronous acceptance by Power Automate.
Status-code logging tests
tests/test_ms_teams_send.py
New parametrized tests with a mocked response helper verify logging.error is called only for 400/500 responses, and not for 200/201/202.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: treating HTTP 202 as success for MS Teams Power Automate webhooks.
Description check ✅ Passed The description matches the changeset and explains the 202 Accepted logging issue and fix.
Linked Issues check ✅ Passed The code change and tests satisfy #1893 by treating HTTP 202 as success and preserving failure logging.
Out of Scope Changes check ✅ Passed No unrelated changes are introduced beyond the MS Teams 202 success handling and its tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

Error when using with MS Teams sink

1 participant