Slack notifications: feedback issue titles containing newlines render as raw mrkdwn instead of a link
Environment
SaaS (https://sentry.io/)
Steps to Reproduce
-
Install the Slack integration and add an issue alert that posts new User Feedback issues to a Slack channel.
-
Submit user feedback whose message contains line breaks. For example, via the Android SDK:
Sentry.feedback().capture(Feedback("the app freezes on checkout\n\nreproduced twice")) -
Open the resulting Slack notification.
Expected Result
The notification renders a clickable link to the feedback, the same as it does when the feedback message is a single line.
Actual Result
The link prints as literal mrkdwn text, and nothing in the message is clickable:
<https://<org>.sentry.io/feedback/?referrer=slack¬ification_uid=…&workflow_id=…&alert_type=issue&feedbackSlug=…&project=…|*User Feedback: the app freezes on checkout
reproduced twice*>
Cause: Sentry titles a feedback issue User Feedback: <message verbatim>, so any newline the reporter typed becomes part of the issue title. The Slack message builder then interpolates that title into mrkdwn link syntax (<url|*title*>), and Slack only parses that syntax when the label sits on a single line. Feedback submitted as one line is unaffected, so this only shows up for multiline reports.
Suggested fix: sanitize the link label when building the Slack message, by collapsing or escaping newlines, or by truncating the title to its first line.
Possibly related: getsentry/sentry#109694, where bold formatting inside a link breaks rendering on Slack mobile. Both originate from the same <url|*title*> pattern in the Slack message builders.
Product Area
Alerts
Auto-routing to @getsentry/product-owners-settings-integrations for triage ⏲️
I traced this to the title interpolation in message_builder/issues.py: escape_slack_text() preserves newlines, so the <url|*title*> label becomes invalid mrkdwn for multiline feedback titles. I can keep the change narrow by normalizing line breaks only in the link label and add a regression case to the existing Slack message builder tests. Is that scope okay to take once product owner triage is done?
I've opened #124244: link labels are now escaped via a new escape_slack_link_label() helper that collapses newline runs into spaces (the sanitize-the-label fix suggested in this issue), and the inline *bold* formatting was removed from labels since it breaks rendering on Slack mobile (#109694). Multiline feedback titles now render as single-line clickable links.
Got it, #124244 covers the same scope I proposed and also handles the Slack mobile formatting issue. I will step back from this one and leave the implementation with you.
Hi, I'd like to take a look at this — the root cause makes sense (newline in the feedback title breaking Slack's <url|*title*> mrkdwn syntax). Will look at the Slack message builder and sanitize/truncate the title used in the link label, plus add a regression test. Will open a PR.
Hi, thanks for the clear write-up — the root cause makes sense to me. I noticed #124244 tried to fix this but was closed by the stale bot without review, and the later claim from September didn't turn into a PR, so I'd like to take a shot at a minimal version of the fix: collapse the title to a single line inside get_title_block only (leaving escape_slack_text untouched, since other call sites rely on newlines), plus a small regression test. I'll open a PR shortly — please let me know if someone else is already working on this.