fix(integrations): stop using mrkdwn formatting inside Slack link labels - #124244
Open
parh0m2007 wants to merge 1 commit into
Open
fix(integrations): stop using mrkdwn formatting inside Slack link labels#124244parh0m2007 wants to merge 1 commit into
parh0m2007 wants to merge 1 commit into
Conversation
Slack only parses the <url|label> link syntax when the label sits on a single line, and inline mrkdwn formatting (e.g. *bold*) inside the label is not rendered by some clients — notably Slack mobile, where alert titles render as plain text instead of links. Titles may also contain newlines (e.g. multiline user feedback becomes an issue title), which renders the whole message as literal mrkdwn text. Add escape_slack_link_label() which escapes text and collapses newlines, and use plain labels everywhere a <url|label> link is built: issue alerts, generic notifications, and incident/metric alerts. Fixes getsentry#109694 Fixes getsentry#121520
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two related bugs, both rooted in the
<url|*bold label*>pattern used by Sentry's Slack message builders:Bold inside link labels breaks Slack mobile (Slack alert notifications render as plain text on mobile (Android) due to bold formatting inside links #109694) — On Slack for Android, alert titles render as plain text instead of clickable links. Slack support confirmed this is a known mobile bug triggered by mrkdwn formatting (e.g.
*...*) inside a link label; their recommended workaround is to use<url|text>without inline formatting.Newlines in labels break the link syntax everywhere (Slack notifications: feedback issue titles containing newlines render as raw mrkdwn instead of a link #121520) — User feedback messages can contain line breaks, and the feedback issue title ("User Feedback: ") becomes the notification link label. Slack only parses the
<url|label>syntax when the label is on a single line, so the whole message renders as literal mrkdwn text and nothing is clickable. Affects issue alerts, metric alerts, incident alerts, and notification digests.Closes #109694
Closes #121520
Solution
Add
escape_slack_link_label()insrc/sentry/integrations/slack/utils/escape.py: appliesescape_slack_textand collapses newline runs into single spaces (per the fix suggested in #121520).Use it for plain (unformatted) labels everywhere a
<url|label>link is built:message_builder/issues.py— issue alert titles (also fixes the newline case)message_builder/notifications/base.py— generic notifications (metric alerts, digests, activity notifications)message_builder/incidents.py— incident alert fallback textnotifications/platform/slack/renderers/metric_alert.py— new-platform metric alert fallback textEmojis and standalone bold text outside links are unchanged; only formatting inside link labels is dropped.
Recipes
<url|title>renders as a clickable link (bold visual change is acceptable per Slack's own recommendation)Evidence
tests/sentry/integrations/slack/**andtests/sentry/notifications/platform/slack/**ruff checkandruff format --checkpass on all touched filesLegal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.