Skip to content

fix(alerts): Fix alert link unfurling URL#111033

Open
malwilley wants to merge 1 commit intomasterfrom
malwilley/slack-unfurl-alert-rule
Open

fix(alerts): Fix alert link unfurling URL#111033
malwilley wants to merge 1 commit intomasterfrom
malwilley/slack-unfurl-alert-rule

Conversation

@malwilley
Copy link
Member

@malwilley malwilley commented Mar 18, 2026

Ref https://linear.app/getsentry/issue/ISWF-769/slack-metric-alert-link-unfurls-not-working

Looks like we're still using the URLs from the old navigation (/alerts/) and never updated to the new pathname /issues/alerts.

I don't think this will actually fix the problem completely, but it will at least get us closer to getting working unfurl links.

@malwilley malwilley requested a review from a team March 18, 2026 21:38
@malwilley malwilley requested review from a team as code owners March 18, 2026 21:38
@linear-code
Copy link

linear-code bot commented Mar 18, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 18, 2026
Comment on lines 184 to 190
metric_alerts_link_regex = re.compile(
r"^https?\://(?#url_prefix)[^/]+/organizations/(?P<org_slug>[^/]+)/alerts/rules/details/(?P<alert_rule_id>\d+)"
r"^https?\://(?#url_prefix)[^/]+/organizations/(?P<org_slug>[^/]+)/issues/alerts/rules/details/(?P<alert_rule_id>\d+)"
)

customer_domain_metric_alerts_link_regex = re.compile(
r"^https?\://(?P<org_slug>[^/]+?)\.(?#url_prefix)[^/]+/alerts/rules/details/(?P<alert_rule_id>\d+)"
r"^https?\://(?P<org_slug>[^/]+?)\.(?#url_prefix)[^/]+/issues/alerts/rules/details/(?P<alert_rule_id>\d+)"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: The URL generation for metric alerts produces the old format (/alerts/rules/details/), but the updated Slack unfurling regex only matches the new format (/issues/alerts/rules/details/), causing unfurling to fail.
Severity: HIGH

Suggested Fix

Update the Django URL pattern for sentry-metric-alert-details in src/sentry/web/urls.py to use the new path /issues/alerts/rules/details/. This will ensure that generated URLs match the format expected by the new unfurling regex.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/integrations/slack/unfurl/metric_alerts.py#L184-L190

Potential issue: The pull request updated the regex in
`src/sentry/integrations/slack/unfurl/metric_alerts.py` to match metric alert URLs with
the path `/issues/alerts/rules/details/`. However, the backend code that generates these
URLs was not updated. The `build_title_link` function still uses the Django URL pattern
`sentry-metric-alert-details` from `src/sentry/web/urls.py`, which resolves to the old
path `/alerts/rules/details/`. As a result, URLs sent in Slack notifications will have
the old format, which the new unfurling logic will not recognize. This will cause metric
alert link unfurling in Slack to silently fail.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is referring to the routes in web/urls.py which only route requests to the react frontend and don't actually define which routes are valid. We still have the old /alerts/ route in there for redirecting purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants