diff --git a/src/sentry/seer/similarity/grouping_records.py b/src/sentry/seer/similarity/grouping_records.py index 2e7e3523a71ebf..461b0b1e3c07f3 100644 --- a/src/sentry/seer/similarity/grouping_records.py +++ b/src/sentry/seer/similarity/grouping_records.py @@ -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( @@ -69,7 +70,7 @@ 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) @@ -77,7 +78,7 @@ def post_bulk_grouping_records( 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( diff --git a/src/sentry/tasks/embeddings_grouping/backfill_seer_grouping_records_for_project.py b/src/sentry/tasks/embeddings_grouping/backfill_seer_grouping_records_for_project.py index 37129851b84124..9a62146e02a309 100644 --- a/src/sentry/tasks/embeddings_grouping/backfill_seer_grouping_records_for_project.py +++ b/src/sentry/tasks/embeddings_grouping/backfill_seer_grouping_records_for_project.py @@ -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")) diff --git a/tests/sentry/seer/similarity/test_grouping_records.py b/tests/sentry/seer/similarity/test_grouping_records.py index 11c69706b6290d..06a24ab40b8771 100644 --- a/tests/sentry/seer/similarity/test_grouping_records.py +++ b/tests/sentry/seer/similarity/test_grouping_records.py @@ -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" ) @@ -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"\n\n500 Internal Server Error\n

Internal Server Error

\n

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.

\n", reason="INTERNAL SERVER ERROR",