diff --git a/src/sentry/incidents/endpoints/serializers/alert_rule_trigger_action.py b/src/sentry/incidents/endpoints/serializers/alert_rule_trigger_action.py index 25862352261669..fc9d5dd6ed1d94 100644 --- a/src/sentry/incidents/endpoints/serializers/alert_rule_trigger_action.py +++ b/src/sentry/incidents/endpoints/serializers/alert_rule_trigger_action.py @@ -32,6 +32,8 @@ def human_desc( return "Send a notification to " + target.get_email() elif target_type == AlertRuleTriggerAction.TargetType.TEAM.value: return "Send an email to members of #" + target.slug + else: + return "Send a notification to [removed]" elif action_type == AlertRuleTriggerAction.Type.OPSGENIE.value: if priority: return f"Send a {priority} Opsgenie notification to {target_display}" diff --git a/src/sentry/notifications/notification_action/group_type_notification_registry/handlers/metric_alert_registry_handler.py b/src/sentry/notifications/notification_action/group_type_notification_registry/handlers/metric_alert_registry_handler.py index eed7d65f19a224..1c46317bb6b93d 100644 --- a/src/sentry/notifications/notification_action/group_type_notification_registry/handlers/metric_alert_registry_handler.py +++ b/src/sentry/notifications/notification_action/group_type_notification_registry/handlers/metric_alert_registry_handler.py @@ -46,10 +46,14 @@ def target(action: Action) -> OrganizationMember | Team | str | None: target_type = action.config.get("target_type") if target_type == ActionTarget.USER.value: dcga = DataConditionGroupAction.objects.get(action=action) - return OrganizationMember.objects.get( - user_id=int(target_identifier), - organization=dcga.condition_group.organization, - ) + try: + return OrganizationMember.objects.get( + user_id=int(target_identifier), + organization=dcga.condition_group.organization, + ) + except OrganizationMember.DoesNotExist: + # user is no longer a member of the organization + pass elif target_type == ActionTarget.TEAM.value: try: return Team.objects.get(id=int(target_identifier))