sentry icon indicating copy to clipboard operation
sentry copied to clipboard

Slack notifications: feedback issue titles containing newlines render as raw mrkdwn instead of a link

Open yoonshikcape opened this issue 3 months ago • 7 comments

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

  1. Install the Slack integration and add an issue alert that posts new User Feedback issues to a Slack channel.

  2. 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"))
    
  3. 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&notification_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

yoonshikcape avatar Aug 07 '26 14:08 yoonshikcape

ENG-8391

linear-code[bot] avatar Aug 07 '26 14:08 linear-code[bot]

Auto-routing to @getsentry/product-owners-settings-integrations for triage ⏲️

getsantry[bot] avatar Aug 07 '26 14:08 getsantry[bot]

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?

ASVLCII avatar Sep 10 '26 15:09 ASVLCII

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.

parh0m2007 avatar Sep 12 '26 16:09 parh0m2007

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.

ASVLCII avatar Sep 13 '26 08:09 ASVLCII

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.

neevmodh avatar Sep 22 '26 18:09 neevmodh

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.

Ultroncn avatar Nov 15 '26 00:11 Ultroncn