Skip to content

fix(slack): Use workflow environment in issue alert links - #126113

Open
sentry-junior[bot] wants to merge 2 commits into
masterfrom
athenamoghaddam/iswf-3420-slack-issue-alert-links-use-the-wrong-environment-query
Open

sentry-junior[bot] wants to merge 2 commits into
masterfrom
athenamoghaddam/iswf-3420-slack-issue-alert-links-use-the-wrong-environment-query

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Slack issue alert links can have the wrong environment query param, e.g. environment=development on a production alert.

When an issue alert fires through the workflow engine, the Rule built for the notification carries both workflow_id and legacy_rule_id. get_rule_or_workflow_id prefers legacy_rule_id, so SlackIssuesMessageBuilder re-read environment_id from the legacy Rule row. That row keeps whatever environment it had at migration time. Workflow edits (WorkflowValidator.update) never write back to it, and the legacy rule edit endpoints are gone. So once a workflow's environment was changed, the link kept showing the old one.

The fix: whenever the rule data has a workflow_id, read the environment from that Workflow. When there's no workflow, it still falls back to the legacy Rule, as before. The alert link and alert_rule_id params don't change.

Added a regression test: it migrates a development rule, moves the workflow to production, and checks that the link says environment=production. The test failed on master with environment=development and passes with this change.

Fixes ISWF-3420
Fixes #123541

via Athena Moghaddam.

--

View Junior Session [Sentry]

Slack issue alert links read the environment from the legacy Rule whenever
a legacy_rule_id was present. Migrated legacy Rules keep the environment
they had at migration time and aren't updated when the workflow is edited,
so links could carry a stale environment (e.g. development instead of
production). Prefer the workflow's environment whenever a workflow fired.

Fixes ISWF-3420
@linear-code

linear-code Bot commented Sep 30, 2026

Copy link
Copy Markdown

ISWF-3420

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 30, 2026
@sentaur-athena sentaur-athena added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Sep 30, 2026
@sentaur-athena
sentaur-athena marked this pull request as ready for review September 30, 2026 22:43
@sentaur-athena
sentaur-athena requested a review from a team as a code owner September 30, 2026 22:43
@kcons

kcons commented Sep 30, 2026

Copy link
Copy Markdown
Member

oh hey, I have this fixed applied a bit more generally in one of my pile of local branches. Let me check if it is close enough to make this unnecessary..

Comment thread tests/sentry/integrations/slack/notifications/test_issue_alert.py
@kcons

kcons commented Sep 30, 2026

Copy link
Copy Markdown
Member

ah yes, #126074. Kinda tacked on there, tbh.

This branch has not been deployed

No deployments
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 Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack issue alert links use the wrong environment query parameter

2 participants