Skip to content

Commit d9e4aa5

Browse files
authored
fix(merged-issues): Update grouphash endpoint to use simple serializer (#81017)
Switching to a simple serializer for the grouphash endpoint. This endpoint is used to load the merged-issues page on an issue and doesn't need to gather all the extra info (stacktrace, packages, tags, etc) about all events in order to populate the page. Fixes #80961
1 parent abde780 commit d9e4aa5

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/sentry/api/serializers/models/event.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ def serialize(self, obj, attrs, user, **kwargs):
586586
"platform": str,
587587
"dateCreated": datetime,
588588
"crashFile": str | None,
589+
"metadata": dict[str, Any] | None,
589590
},
590591
)
591592

@@ -642,6 +643,7 @@ def serialize(self, obj: BaseEvent, attrs, user, **kwargs) -> SimpleEventSeriali
642643
"dateCreated": obj.datetime,
643644
# Needed to generate minidump links in UI
644645
"crashFile": attrs["crash_file"],
646+
"metadata": obj.get_event_metadata(),
645647
}
646648

647649
return response

src/sentry/apidocs/examples/event_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"location": "example.py:123",
2929
"culprit": "/books/new/",
3030
"projectID": "49271",
31+
"metadata": None,
3132
}
3233

3334
GROUP_EVENT: GroupEventDetailsResponse = {

src/sentry/issues/endpoints/group_hashes.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from sentry.api.base import region_silo_endpoint
99
from sentry.api.bases import GroupEndpoint
1010
from sentry.api.paginator import GenericOffsetPaginator
11-
from sentry.api.serializers import EventSerializer, serialize
11+
from sentry.api.serializers import EventSerializer, SimpleEventSerializer, serialize
1212
from sentry.models.grouphash import GroupHash
1313
from sentry.tasks.unmerge import unmerge
1414
from sentry.utils import metrics
@@ -31,8 +31,10 @@ def get(self, request: Request, group) -> Response:
3131
checksums used to aggregate individual events.
3232
3333
:pparam string issue_id: the ID of the issue to retrieve.
34+
:pparam bool full: If this is set to true, the event payload will include the full event body, including the stacktrace.
3435
:auth: required
3536
"""
37+
full = request.GET.get("full", True)
3638

3739
data_fn = partial(
3840
lambda *args, **kwargs: raw_query(*args, **kwargs)["data"],
@@ -47,7 +49,9 @@ def get(self, request: Request, group) -> Response:
4749
tenant_ids={"organization_id": group.project.organization_id},
4850
)
4951

50-
handle_results = partial(self.__handle_results, group.project_id, group.id, request.user)
52+
handle_results = partial(
53+
self.__handle_results, group.project_id, group.id, request.user, full
54+
)
5155

5256
return self.paginate(
5357
request=request,
@@ -90,13 +94,16 @@ def put(self, request: Request, group) -> Response:
9094

9195
return Response(status=202)
9296

93-
def __handle_results(self, project_id, group_id, user, results):
94-
return [self.__handle_result(user, project_id, group_id, result) for result in results]
97+
def __handle_results(self, project_id, group_id, user, full, results):
98+
return [
99+
self.__handle_result(user, project_id, group_id, full, result) for result in results
100+
]
95101

96-
def __handle_result(self, user, project_id, group_id, result):
102+
def __handle_result(self, user, project_id, group_id, full, result):
97103
event = eventstore.backend.get_event_by_id(project_id, result["event_id"])
98104

105+
serializer = EventSerializer if full else SimpleEventSerializer
99106
return {
100107
"id": result["primary_hash"],
101-
"latestEvent": serialize(event, user, EventSerializer()),
108+
"latestEvent": serialize(event, user, serializer()),
102109
}

0 commit comments

Comments
 (0)