Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/sentry/seer/similarity/grouping_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CreateGroupingRecordsRequest(TypedDict):
class BulkCreateGroupingRecordsResponse(TypedDict):
success: bool
groups_with_neighbor: NotRequired[dict[str, RawSeerSimilarIssueData]]
reason: NotRequired[str | None]


seer_grouping_connection_pool = connection_from_url(
Expand Down Expand Up @@ -69,15 +70,15 @@ def post_bulk_grouping_records(
except ReadTimeoutError:
extra.update({"reason": "ReadTimeoutError", "timeout": POST_BULK_GROUPING_RECORDS_TIMEOUT})
logger.info("seer.post_bulk_grouping_records.failure", extra=extra)
return {"success": False}
return {"success": False, "reason": "ReadTimeoutError"}

if response.status >= 200 and response.status < 300:
logger.info("seer.post_bulk_grouping_records.success", extra=extra)
return json.loads(response.data.decode("utf-8"))
else:
extra.update({"reason": response.reason})
logger.info("seer.post_bulk_grouping_records.failure", extra=extra)
return {"success": False}
return {"success": False, "reason": response.reason}


def delete_project_grouping_records(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def backfill_seer_grouping_records_for_project(
extra={
"current_project_id": current_project_id,
"last_processed_project_index": last_processed_project_index,
"reason": seer_response.get("reason"),
},
)
sentry_sdk.capture_exception(Exception("Seer failed during backfill"))
Expand Down
4 changes: 2 additions & 2 deletions tests/sentry/seer/similarity/test_grouping_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_post_bulk_grouping_records_success(mock_seer_request: MagicMock, mock_l
@mock.patch("sentry.seer.similarity.grouping_records.logger")
@mock.patch("sentry.seer.similarity.grouping_records.seer_grouping_connection_pool.urlopen")
def test_post_bulk_grouping_records_timeout(mock_seer_request: MagicMock, mock_logger: MagicMock):
expected_return_value = {"success": False}
expected_return_value = {"success": False, "reason": "ReadTimeoutError"}
mock_seer_request.side_effect = ReadTimeoutError(
DUMMY_POOL, settings.SEER_AUTOFIX_URL, "read timed out"
)
Expand All @@ -91,7 +91,7 @@ def test_post_bulk_grouping_records_timeout(mock_seer_request: MagicMock, mock_l
@mock.patch("sentry.seer.similarity.grouping_records.logger")
@mock.patch("sentry.seer.similarity.grouping_records.seer_grouping_connection_pool.urlopen")
def test_post_bulk_grouping_records_failure(mock_seer_request: MagicMock, mock_logger: MagicMock):
expected_return_value = {"success": False}
expected_return_value = {"success": False, "reason": "INTERNAL SERVER ERROR"}
mock_seer_request.return_value = HTTPResponse(
b"<!doctype html>\n<html lang=en>\n<title>500 Internal Server Error</title>\n<h1>Internal Server Error</h1>\n<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>\n",
reason="INTERNAL SERVER ERROR",
Expand Down