Skip to content

fix(notifications): update Shoutrrr MS Teams integration - #1718

Merged
nicholas-fedor merged 5 commits into
mainfrom
fix/legacy-teams-notifications
Jun 3, 2026
Merged

fix(notifications): update Shoutrrr MS Teams integration#1718
nicholas-fedor merged 5 commits into
mainfrom
fix/legacy-teams-notifications

Conversation

@nicholas-fedor

@nicholas-fedor nicholas-fedor commented Jun 2, 2026

Copy link
Copy Markdown
Owner

This PR updates the Microsoft Teams notification integration to work with the updated Shoutrrr MS Teams service SDK, which removed ConfigFromWebhookURL() and changed the webhook format from legacy outlook.office.com/webhookb2/... URLs to Power Automate workflow URLs. It also removes the dead --notification-msteams-data flag that was registered but never consumed.

Problems

A recent change to Microsoft Teams webhook format was recently implemented in Shoutrrr's MS Teams service. This change removed ConfigFromWebhookURL() and changed the webhook URL format, causing a compiler error (undefined: teams.ConfigFromWebhookURL). The test suite also used the old webhook format and expected the old teams://path?... URL serialization. Additionally, the --notification-msteams-data flag was dead code — registered in flags.go and parsed in msteams.go but never stored or used in any behavior.

Solution

Updated the Teams notifier to construct teams.Config directly with the full Power Automate workflow URL as Config.Host, which is the new SDK pattern. Removed the dead --notification-msteams-data flag registration, parsing, and all documentation references. Updated tests and docs to use the current webhook URL format.

Changes

  • pkg/notifications/msteams.go — replaced teams.ConfigFromWebhookURL() with direct teams.Config{Host: webhookURL, Color: ColorHex} construction; removed data field, errConfigWebhookFailed sentinel, and dead flag parsing
  • pkg/notifications/notifier_test.go — updated test to use Power Automate workflow URL and new teams:?color=...&host=... URL format
  • internal/flags/flags.go — removed --notification-msteams-data flag registration
  • docs/notifications/overview/index.md — updated all 3 code examples with new webhook URL, removed MSTeams Use Log Data config section, fixed env var references
  • docs/configuration/arguments/index.md — fixed env var name WATCHTOWER_NOTIFICATION_MSTEAMS_HOOKWATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL

Summary by CodeRabbit

  • Documentation

    • Updated Microsoft Teams notification docs: renamed environment variable for the Teams hook, replaced example webhook with a Power Automate webhook, and added a warning that the hook must be an absolute https:// URL.
  • Refactor

    • Simplified Microsoft Teams notifier and removed the log-data extraction option; notifier now expects a single webhook URL.

- Replace `ConfigFromWebhookURL` with direct `teams.Config` construction using the full webhook URL as host
- Remove `data` field and `errConfigWebhookFailed` error that are no longer needed
- Update test to use a Power Automate workflow URL instead of an Office 365 webhook URL
- Adjust expected test output to match the new `teams:?color=...&host=...` URL format
- Update MSTeams docs for Power Automate webhook URLs
- Fix MSTeams docs with correct configuration name
- Validate that MSTeams webhook URLs use HTTPS scheme and contain a host
- Remove `--notification-msteams-data` flag and `WATCHTOWER_NOTIFICATION_MSTEAMS_USE_LOG_DATA` env var
- Strip MSTeams log data documentation and example references
- Simplify MSTeams notifier initialization by removing unused withData logic
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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: 5fa2ebe0-baa2-49b3-81a9-9003554eb5ed

📥 Commits

Reviewing files that changed from the base of the PR and between 13825da and 6f3eecf.

📒 Files selected for processing (1)
  • docs/notifications/overview/index.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/notifications/overview/index.md

📝 Walkthrough

Walkthrough

This PR simplifies Microsoft Teams notification configuration by removing the data extraction flag, renaming the webhook environment variable to WATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL, and rewriting the webhook URL handling logic to directly validate HTTPS URLs instead of using a shared helper function. Documentation and tests are updated accordingly.

Changes

MSTeams notification configuration update

Layer / File(s) Summary
MSTeams notifier configuration contract
pkg/notifications/msteams.go, internal/flags/flags.go
msTeamsTypeNotifier struct retains only webHookURL field; newMsTeamsNotifier constructor simplified to initialize with URL alone; flag registration updated to bind notification-msteams-hook to WATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL.
Webhook URL handling logic and test
pkg/notifications/msteams.go, pkg/notifications/notifier_test.go
GetURL method rewritten to parse and validate webhook URL as absolute HTTPS URL, constructing teams.Config directly with full URL as Host; test case updated to validate new query-string-based URL format (teams:?color=...&host=...) and Power Automate webhook structure.
Configuration flag and environment variable documentation
docs/configuration/arguments/index.md
Flags-to-environment-variable mapping table and dedicated "Notification Microsoft Teams Hook" option section updated to reference new WATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL environment variable name.
Microsoft Teams notifications configuration overview
docs/notifications/overview/index.md
Example configurations (Docker CLI env vars, CLI flags, Docker Compose) and configuration options section updated to use Power Automate workflow webhook URL; deprecated "MSTeams Use Log Data" option (--notification-msteams-data) removed; added warning that --notification-msteams-hook must be an absolute https:// URL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • nicholas-fedor/watchtower#1463: Both PRs modify pkg/notifications/msteams.go webhook URL handling in GetURL—PR #1463 adjusts the teams.ConfigFromWebhookURL call-site, while this PR removes that call entirely and rewrites the method to validate HTTPS URLs directly.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(notifications): update Shoutrrr MS Teams integration' directly describes the main objective: updating the MS Teams integration in the notifications system to align with Shoutrrr SDK changes and fix/remove legacy flag support.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

@codacy-production

codacy-production Bot commented Jun 2, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/notifications/msteams.go 71.42% 1 Missing and 1 partial ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1718      +/-   ##
==========================================
- Coverage   74.59%   74.23%   -0.36%     
==========================================
  Files          60       61       +1     
  Lines       10052    10188     +136     
==========================================
+ Hits         7498     7563      +65     
- Misses       2286     2347      +61     
- Partials      268      278      +10     
Files with missing lines Coverage Δ
internal/flags/flags.go 86.21% <ø> (ø)
pkg/notifications/msteams.go 55.55% <71.42%> (-2.03%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/notifications/overview/index.md (1)

827-831: ⚡ Quick win

Document the HTTPS/absolute URL requirement explicitly.

Please state that --notification-msteams-hook must be an absolute https:// URL (with host), matching runtime validation in pkg/notifications/msteams.go.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/notifications/overview/index.md` around lines 827 - 831, Update the
MSTeams Hook URL docs block in docs/notifications/overview/index.md to
explicitly require that the --notification-msteams-hook flag value is an
absolute https:// URL including the host (no relative URLs, must use HTTPS), and
note that this matches the runtime validation implemented in
pkg/notifications/msteams.go; mention the exact flag name
(--notification-msteams-hook) and the HTTPS/absolute requirement so users know
the expected format.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/notifications/msteams.go`:
- Around line 76-82: The code is incorrectly passing the entire Power Automate
webhook URL into teams.Config.Host (n.webHookURL) — change
pkg/notifications/msteams.go so you either (A) extract only the legacy Teams
webhook hostname (e.g., organization.webhook.office.com) and set that into
teams.Config.Host before calling config.GetURL(), or (B) when the provided
webhook is a full Power Automate/workflow URL, do not use teams.Config at all
and instead construct a shoutrrr generic service URL
(generic://<full-webhook>?contenttype=text/plain) and use the generic sender;
update the logic around teams.Config, n.webHookURL, and config.GetURL()
accordingly and adjust tests in notifier_test.go to expect the generic URL for
Power Automate-style hooks.

---

Nitpick comments:
In `@docs/notifications/overview/index.md`:
- Around line 827-831: Update the MSTeams Hook URL docs block in
docs/notifications/overview/index.md to explicitly require that the
--notification-msteams-hook flag value is an absolute https:// URL including the
host (no relative URLs, must use HTTPS), and note that this matches the runtime
validation implemented in pkg/notifications/msteams.go; mention the exact flag
name (--notification-msteams-hook) and the HTTPS/absolute requirement so users
know the expected format.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 84d186d2-bd94-40db-b3d1-9f19e489f6fb

📥 Commits

Reviewing files that changed from the base of the PR and between cf0c9ac and 13825da.

📒 Files selected for processing (5)
  • docs/configuration/arguments/index.md
  • docs/notifications/overview/index.md
  • internal/flags/flags.go
  • pkg/notifications/msteams.go
  • pkg/notifications/notifier_test.go
💤 Files with no reviewable changes (1)
  • internal/flags/flags.go

Comment thread pkg/notifications/msteams.go
@nicholas-fedor
nicholas-fedor merged commit 9b7d3d4 into main Jun 3, 2026
19 of 20 checks passed
@nicholas-fedor
nicholas-fedor deleted the fix/legacy-teams-notifications branch June 3, 2026 00:13
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.

1 participant