Skip to content

Commit 7c6abcc

Browse files
JerrySentryandrewshie-sentry
authored andcommitted
feat(bug-prediction): Also fetch error message for get_issues_related_to_exception_type call (#97579)
- Don't just fetch the issue IDs, also return the error message (eg: `OutboxDatabaseError: Failed to process Outbox, TEAM_UPDATE due to database error`) - This will be used by the bug prediction tool when a user's repo does not have seer setup so they can not retrieve the seer summaries from the issue IDs, so we will at least provide the error message to the AI agent to look at instead of nothing closes: https://linear.app/getsentry/issue/AIML-931/return-issue-message-as-part-of-initial-fetch ### Legal Boilerplate Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
1 parent 5c2b9be commit 7c6abcc

File tree

2 files changed

+55
-9
lines changed

2 files changed

+55
-9
lines changed

src/sentry/seer/fetch_issues/fetch_issues_given_exception_type.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,13 @@ def get_issues_related_to_exception_type(
127127
)
128128
.order_by("last_seen")[:max_num_issues]
129129
)
130-
return {"issues": [issue.id for issue in query_set]}
130+
return {
131+
"issues": [issue.id for issue in query_set],
132+
"issues_with_message": [
133+
{
134+
"id": issue.id,
135+
"message": issue.data.get("title") if issue.data else "",
136+
}
137+
for issue in query_set
138+
],
139+
}

tests/sentry/seer/fetch_issues/test_fetch_issues_given_exception_type.py

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ def test_simple(self) -> None:
4747
external_id="1",
4848
exception_type="KeyError",
4949
)
50-
assert group_ids == {"issues": [group.id]}
50+
assert group_ids == {
51+
"issues": [group.id],
52+
"issues_with_message": [
53+
{
54+
"id": group.id,
55+
"message": "KeyError: This a bad error",
56+
}
57+
],
58+
}
5159

5260
# Assert that ValueError did not match the exception type
5361
group_ids = get_issues_related_to_exception_type(
@@ -56,7 +64,7 @@ def test_simple(self) -> None:
5664
external_id="1",
5765
exception_type="ValueError",
5866
)
59-
assert group_ids == {"issues": []}
67+
assert group_ids == {"issues": [], "issues_with_message": []}
6068

6169
# Assert latest event is returned
6270
results = get_latest_issue_event(group.id)
@@ -149,7 +157,8 @@ def test_multiple_projects(self) -> None:
149157
exception_type="KeyError",
150158
)
151159
assert {group_1.id, group_2.id} == set(group_ids["issues"])
152-
assert group_3.id not in group_ids
160+
assert group_3.id not in group_ids["issues"]
161+
assert group_3.id not in [issue["id"] for issue in group_ids["issues_with_message"]]
153162

154163
# Assert latest event is returned
155164
results = get_latest_issue_event(group_1.id)
@@ -196,7 +205,15 @@ def test_last_seen_filter(self) -> None:
196205
external_id="1",
197206
exception_type="KeyError",
198207
)
199-
assert group_ids == {"issues": [group.id]}
208+
assert group_ids == {
209+
"issues": [group.id],
210+
"issues_with_message": [
211+
{
212+
"id": group.id,
213+
"message": "KeyError: This a bad error",
214+
}
215+
],
216+
}
200217

201218
# Assert that KeyError matched the exception type
202219
group_ids = get_issues_related_to_exception_type(
@@ -206,7 +223,7 @@ def test_last_seen_filter(self) -> None:
206223
exception_type="KeyError",
207224
num_days_ago=9,
208225
)
209-
assert group_ids == {"issues": []}
226+
assert group_ids == {"issues": [], "issues_with_message": []}
210227

211228
# Assert latest event is returned
212229
results = get_latest_issue_event(group.id)
@@ -230,7 +247,11 @@ def test_multiple_exception_types(self) -> None:
230247
data={
231248
**data,
232249
"release": release.version,
233-
"exception": {"values": [{"type": "KeyError", "data": {"values": []}}]},
250+
"exception": {
251+
"values": [
252+
{"type": "KeyError", "value": "voodoo curse", "data": {"values": []}}
253+
]
254+
},
234255
},
235256
project_id=self.project.id,
236257
)
@@ -265,7 +286,15 @@ def test_multiple_exception_types(self) -> None:
265286
external_id="1",
266287
exception_type="KeyError",
267288
)
268-
assert group_ids == {"issues": [group_1.id]}
289+
assert group_ids == {
290+
"issues": [group_1.id],
291+
"issues_with_message": [
292+
{
293+
"id": group_1.id,
294+
"message": "KeyError: voodoo curse",
295+
}
296+
],
297+
}
269298

270299
# Assert that ValueError matched the exception type
271300
group_ids = get_issues_related_to_exception_type(
@@ -274,7 +303,15 @@ def test_multiple_exception_types(self) -> None:
274303
external_id="1",
275304
exception_type="ValueError",
276305
)
277-
assert group_ids == {"issues": [group_2.id]}
306+
assert group_ids == {
307+
"issues": [group_2.id],
308+
"issues_with_message": [
309+
{
310+
"id": group_2.id,
311+
"message": "ValueError: This a bad error",
312+
}
313+
],
314+
}
278315

279316
# Assert latest event is returned
280317
results = get_latest_issue_event(group_2.id)

0 commit comments

Comments
 (0)