Skip to content

Commit 8db0135

Browse files
authored
fix(aci): Use notification_uuid from WorkflowFireHistory when sending notifications (#105471)
When investigating links sent via notification, we usually have access to the notification_uuid url param which is unique per notification. To make this useful, we thread through the notification_uuid from WorkflowFireHistory, which was previously unused, to make it easy to associate with a history entry and thus a workflow/group/etc.
1 parent 56e3619 commit 8db0135

36 files changed

+335
-35
lines changed

src/sentry/integrations/discord/handlers/discord_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import override
2+
13
from sentry.integrations.types import IntegrationProviderSlug
24
from sentry.notifications.models.notificationaction import ActionTarget
35
from sentry.notifications.notification_action.action_handler_registry.base import (
@@ -50,5 +52,6 @@ def get_config_transformer() -> ConfigTransformer | None:
5052
return TargetTypeConfigTransformer.from_config_schema(DiscordActionHandler.config_schema)
5153

5254
@staticmethod
55+
@override
5356
def execute(invocation: ActionInvocation) -> None:
5457
execute_via_group_type_registry(invocation)

src/sentry/integrations/msteams/handlers/msteams_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import override
2+
13
from sentry.integrations.types import IntegrationProviderSlug
24
from sentry.notifications.notification_action.action_handler_registry.base import (
35
IntegrationActionHandler,
@@ -32,5 +34,6 @@ def get_config_transformer() -> ConfigTransformer | None:
3234
return TargetTypeConfigTransformer.from_config_schema(MSTeamsActionHandler.config_schema)
3335

3436
@staticmethod
37+
@override
3538
def execute(invocation: ActionInvocation) -> None:
3639
execute_via_group_type_registry(invocation)

src/sentry/integrations/opsgenie/handlers/opsgenie_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import override
2+
13
from sentry.integrations.opsgenie.utils import OPSGENIE_CUSTOM_PRIORITIES
24
from sentry.integrations.types import IntegrationProviderSlug
35
from sentry.notifications.notification_action.action_handler_registry.base import (
@@ -37,5 +39,6 @@ def get_config_transformer() -> ConfigTransformer | None:
3739
return TargetTypeConfigTransformer.from_config_schema(OpsgenieActionHandler.config_schema)
3840

3941
@staticmethod
42+
@override
4043
def execute(invocation: ActionInvocation) -> None:
4144
execute_via_group_type_registry(invocation)

src/sentry/integrations/pagerduty/handlers/pagerduty_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import override
2+
13
from sentry.integrations.pagerduty.client import PagerdutySeverity
24
from sentry.integrations.types import IntegrationProviderSlug
35
from sentry.notifications.notification_action.action_handler_registry.base import (
@@ -37,5 +39,6 @@ def get_config_transformer() -> ConfigTransformer | None:
3739
return TargetTypeConfigTransformer.from_config_schema(PagerdutyActionHandler.config_schema)
3840

3941
@staticmethod
42+
@override
4043
def execute(invocation: ActionInvocation) -> None:
4144
execute_via_group_type_registry(invocation)

src/sentry/integrations/slack/handlers/slack_action_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import override
2+
13
from sentry.integrations.types import IntegrationProviderSlug
24
from sentry.notifications.notification_action.action_handler_registry.base import (
35
IntegrationActionHandler,
@@ -36,6 +38,7 @@ def get_config_transformer() -> ConfigTransformer | None:
3638
return TargetTypeConfigTransformer.from_config_schema(SlackActionHandler.config_schema)
3739

3840
@staticmethod
41+
@override
3942
def execute(invocation: ActionInvocation) -> None:
4043
from sentry.notifications.notification_action.utils import execute_via_group_type_registry
4144

src/sentry/integrations/slack/utils/notifications.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
get_default_metric_alert_repository,
3333
get_default_notification_action_repository,
3434
)
35+
from sentry.integrations.repository.base import BaseNewNotificationMessage
3536
from sentry.integrations.repository.metric_alert import (
3637
MetricAlertNotificationMessage,
3738
MetricAlertNotificationMessageRepository,
@@ -234,21 +235,17 @@ def _build_notification_payload(
234235
return attachments, text
235236

236237

237-
def _send_notification(
238+
def _send_notification[Msg: BaseNewNotificationMessage, Repo](
238239
integration: RpcIntegration,
239240
metric_issue_context: MetricIssueContext,
240241
attachments: str,
241242
text: str,
242243
channel: str,
243244
thread_ts: str | None,
244245
reply_broadcast: bool,
245-
notification_message_object: (
246-
NewMetricAlertNotificationMessage | NewNotificationActionNotificationMessage
247-
),
248-
save_notification_method: Callable,
249-
repository: (
250-
MetricAlertNotificationMessageRepository | NotificationActionNotificationMessageRepository
251-
),
246+
notification_message_object: Msg,
247+
save_notification_method: Callable[[Msg, Repo], None],
248+
repository: Repo,
252249
) -> bool:
253250
with MessagingInteractionEvent(
254251
interaction_type=MessagingInteractionType.SEND_INCIDENT_ALERT_NOTIFICATION,

src/sentry/notifications/notification_action/action_handler_registry/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
from abc import ABC
3+
from typing import override
34

45
from sentry.integrations.types import IntegrationProviderSlug
56
from sentry.notifications.models.notificationaction import ActionTarget
@@ -59,5 +60,6 @@ def get_config_transformer() -> ConfigTransformer | None:
5960
return TargetTypeConfigTransformer.from_config_schema(TicketingActionHandler.config_schema)
6061

6162
@staticmethod
63+
@override
6264
def execute(invocation: ActionInvocation) -> None:
6365
execute_via_issue_alert_handler(invocation)

src/sentry/notifications/notification_action/action_handler_registry/email_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import override
2+
13
from sentry.notifications.models.notificationaction import ActionTarget
24
from sentry.notifications.notification_action.utils import execute_via_group_type_registry
35
from sentry.notifications.types import FallthroughChoiceType
@@ -62,5 +64,6 @@ def get_config_transformer(cls) -> ConfigTransformer | None:
6264
return cls._config_transformer
6365

6466
@staticmethod
67+
@override
6568
def execute(invocation: ActionInvocation) -> None:
6669
execute_via_group_type_registry(invocation)

src/sentry/notifications/notification_action/action_handler_registry/plugin_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import override
2+
13
from sentry.notifications.notification_action.utils import execute_via_group_type_registry
24
from sentry.workflow_engine.models import Action
35
from sentry.workflow_engine.registry import action_handler_registry
@@ -32,5 +34,6 @@ def get_config_transformer() -> ConfigTransformer | None:
3234
return None
3335

3436
@staticmethod
37+
@override
3538
def execute(invocation: ActionInvocation) -> None:
3639
execute_via_group_type_registry(invocation)

src/sentry/notifications/notification_action/action_handler_registry/sentry_app_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import override
2+
13
from sentry.notifications.models.notificationaction import ActionTarget
24
from sentry.notifications.notification_action.utils import execute_via_group_type_registry
35
from sentry.workflow_engine.models import Action
@@ -46,5 +48,6 @@ def get_config_transformer() -> ConfigTransformer | None:
4648
return TargetTypeConfigTransformer.from_config_schema(SentryAppActionHandler.config_schema)
4749

4850
@staticmethod
51+
@override
4952
def execute(invocation: ActionInvocation) -> None:
5053
execute_via_group_type_registry(invocation)

0 commit comments

Comments
 (0)