Skip to content

Commit 8c310b0

Browse files
fix(np): Updates issue renderer to properly extract tags, notes, event
1 parent c2b23ac commit 8c310b0

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/sentry/notifications/platform/slack/renderers/issue.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from sentry import eventstore
34
from sentry.models.group import Group
45
from sentry.notifications.platform.renderer import NotificationRenderer
56
from sentry.notifications.platform.slack.provider import SlackRenderable
@@ -9,6 +10,7 @@
910
NotificationProviderKey,
1011
NotificationRenderedTemplate,
1112
)
13+
from sentry.services.eventstore.models import Event
1214

1315

1416
class IssueSlackRenderer(NotificationRenderer[SlackRenderable]):
@@ -23,17 +25,18 @@ def render[DataT: NotificationData](
2325

2426
from sentry.integrations.slack.message_builder.issues import SlackIssuesMessageBuilder
2527

26-
group = Group.objects.get_from_cache(id=data.group_id)
27-
event = None
28+
group: Group = Group.objects.get_from_cache(id=data.group_id)
29+
event: Event | None = None
2830
if data.event_id:
29-
event = group.get_latest_event()
31+
event = eventstore.backend.get_event_by_id(group.project.id, data.event_id)
3032

3133
blocks_dict = SlackIssuesMessageBuilder(
3234
group=group,
3335
event=event,
34-
tags=data.tags or None,
36+
tags=data.rule.data.get("tags", "").split(",") or None,
3537
rules=[data.rule.to_rule()] if data.rule else None,
36-
notes=data.notes or None,
38+
notes=data.rule.data.get("notes", None) or None,
39+
link_to_event=True,
3740
).build(notification_uuid=data.notification_uuid)
3841

3942
return SlackRenderable(

src/sentry/notifications/platform/templates/issue.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Any
44

5-
from pydantic import BaseModel, ConfigDict, Field
5+
from pydantic import BaseModel, ConfigDict
66

77
from sentry.models.rule import Rule
88
from sentry.notifications.platform.registry import template_registry
@@ -62,8 +62,6 @@ class IssueNotificationData(NotificationData):
6262
group_id: int
6363
event_id: str | None = None
6464
rule: SerializableRuleProxy | None = None
65-
tags: set[str] = Field(default_factory=set)
66-
notes: str = ""
6765
notification_uuid: str = ""
6866

6967

@@ -73,11 +71,16 @@ class IssueNotificationTemplate(NotificationTemplate[IssueNotificationData]):
7371
example_data = IssueNotificationData(
7472
group_id=1,
7573
event_id="abc123",
76-
tags={"environment", "level"},
77-
notes="example note",
7874
notification_uuid="test-uuid",
7975
rule=SerializableRuleProxy(
80-
id=1, project_id=2, environment_id=3, label="Example Rule", data={}
76+
id=1,
77+
project_id=2,
78+
label="Example Rule",
79+
data={
80+
"actions": [{"workflow_id": 3}],
81+
"tags": "environment,level",
82+
"notes": "example note",
83+
},
8184
),
8285
)
8386
hide_from_debugger = True

0 commit comments

Comments
 (0)