fix(notifications): use regression event data instead of stale group metadata#115871
Draft
sentry-junior[bot] wants to merge 1 commit into
Draft
fix(notifications): use regression event data instead of stale group metadata#115871sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
…metadata When an issue regresses, the notification (Slack and email) was showing the original issue's error message instead of the event that triggered the regression. This happened because: 1. RegressionActivityNotification never loaded the regression event, even though Activity.data stores the event_id 2. The notification fires before group metadata is updated via buffer_incr, so even group-level data was stale Fix: - Load the regression event from activity.data['event_id'] in RegressionActivityNotification.__init__ - Override build_attachment_title and get_title_link to use the regression event when available - Pass event to email template context via get_group_context override - Update _group.html to prefer event metadata over group metadata when an event is present (backwards-compatible via |default filter) - Graceful fallback: if event lookup fails, falls back to existing group-based behavior Fixes: regression notifications showing original error message instead of the error that caused the regression
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
When an issue regresses, both email and Slack notifications show the original issue's error message instead of the event that actually triggered the regression.
For example:
ValueError: missing field 'name'ValueError: timeout connecting to databasetriggers regressionValueError: missing field 'name'← wrongThis was reported by a customer: "the original message from an issue gets posted over and over again even though the latest issue in an issue group is a totally different one."
Root Cause
Two compounding issues:
RegressionActivityNotificationignores the regression event — theActivity.datastoresevent_idbut the notification code never reads it. All downstream renderers fall back to group-level metadata._handle_regressiontriggers the async notification, then_process_existing_aggregateupdates metadata viabuffer_incr(also async). The notification task reads stale group data.Fix
activity.data['event_id']inRegressionActivityNotification.__init__usingeventstore.backend.get_event_by_id()build_attachment_titleandget_title_linkto use the regression event when availableget_group_contextoverride_group.htmlto prefer event metadata over group metadata when present (backwards-compatible via|defaultfilter)Changes
src/sentry/notifications/notifications/activity/regression.pysrc/sentry/templates/sentry/emails/_group.htmltests/.../slack/notifications/test_regression.pyTesting
test_regression_uses_regression_event_metadata— verifies Slack notification shows regression event's error messagetest_regression_without_event_id_falls_back_to_group— verifies graceful fallback when no event_id presentRequested-by: Daniel Griesser daniel@sentry.io