From 0f6431f2bc996bc212c631ee84bedf46b820534a Mon Sep 17 00:00:00 2001 From: anthony sottile Date: Thu, 13 Jun 2024 14:38:45 -0400 Subject: [PATCH] ref: fix typing for event_id (it is str) split out from my Job is TypedDict branch --- src/sentry/api/endpoints/group_ai_autofix.py | 2 +- src/sentry/eventstore/base.py | 8 ++++---- src/sentry/eventstore/reprocessing/base.py | 2 +- src/sentry/eventstore/reprocessing/redis.py | 2 +- src/sentry/eventstore/snuba/backend.py | 6 +++--- src/sentry/issues/related/trace_connected.py | 2 +- src/sentry/reprocessing2.py | 2 +- src/sentry/tasks/post_process.py | 3 ++- tests/relay_integration/test_sdk.py | 1 + 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/sentry/api/endpoints/group_ai_autofix.py b/src/sentry/api/endpoints/group_ai_autofix.py index 4adf59ceefc76d..9146861349be3f 100644 --- a/src/sentry/api/endpoints/group_ai_autofix.py +++ b/src/sentry/api/endpoints/group_ai_autofix.py @@ -48,7 +48,7 @@ class GroupAutofixEndpoint(GroupEndpoint): } def _get_serialized_event( - self, event_id: int, group: Group, user: AbstractBaseUser | AnonymousUser + self, event_id: str, group: Group, user: AbstractBaseUser | AnonymousUser ) -> dict[str, Any] | None: event = eventstore.backend.get_event_by_id(group.project.id, event_id, group_id=group.id) diff --git a/src/sentry/eventstore/base.py b/src/sentry/eventstore/base.py index 30a225256cddbb..7259e980acb680 100644 --- a/src/sentry/eventstore/base.py +++ b/src/sentry/eventstore/base.py @@ -226,12 +226,12 @@ def get_unfetched_events( def get_event_by_id( self, - project_id, - event_id, - group_id=None, + project_id: int, + event_id: str, + group_id: int | None = None, skip_transaction_groupevent=False, tenant_ids=None, - occurrence_id=None, + occurrence_id: str | None = None, ): """ Gets a single event of any event type given a project_id and event_id. diff --git a/src/sentry/eventstore/reprocessing/base.py b/src/sentry/eventstore/reprocessing/base.py index 1a08cf194e9b5f..3d2dfe729035f2 100644 --- a/src/sentry/eventstore/reprocessing/base.py +++ b/src/sentry/eventstore/reprocessing/base.py @@ -45,7 +45,7 @@ def expire_hash( self, project_id: int, group_id: int, - event_id: int, + event_id: str, date_val: datetime, old_primary_hash: str, ) -> None: diff --git a/src/sentry/eventstore/reprocessing/redis.py b/src/sentry/eventstore/reprocessing/redis.py index eb907991e2ac25..fe19f191039939 100644 --- a/src/sentry/eventstore/reprocessing/redis.py +++ b/src/sentry/eventstore/reprocessing/redis.py @@ -93,7 +93,7 @@ def expire_hash( self, project_id: int, group_id: int, - event_id: int, + event_id: str, date_val: datetime, old_primary_hash: str, ) -> None: diff --git a/src/sentry/eventstore/snuba/backend.py b/src/sentry/eventstore/snuba/backend.py index 0fdc96c3061913..6b994253430ee6 100644 --- a/src/sentry/eventstore/snuba/backend.py +++ b/src/sentry/eventstore/snuba/backend.py @@ -299,9 +299,9 @@ def __get_events( def get_event_by_id( self, - project_id, - event_id, - group_id=None, + project_id: int, + event_id: str, + group_id: int | None = None, skip_transaction_groupevent=False, tenant_ids=None, occurrence_id: str | None = None, diff --git a/src/sentry/issues/related/trace_connected.py b/src/sentry/issues/related/trace_connected.py index 98c2ae098f1f56..86b3aede44effd 100644 --- a/src/sentry/issues/related/trace_connected.py +++ b/src/sentry/issues/related/trace_connected.py @@ -28,7 +28,7 @@ def trace_connected_analysis( if event_id: # If we are passing an specific event_id, we need to get the project_id assert project_id is not None - event = eventstore.backend.get_event_by_id(project_id, event_id, group_id=group.id) + event = eventstore.backend.get_event_by_id(int(project_id), event_id, group_id=group.id) # If we are requesting an specific event, we want to be notified with an error assert event is not None # This ensures that the event is actually part of the group and we are notified diff --git a/src/sentry/reprocessing2.py b/src/sentry/reprocessing2.py index 50f4f85b34edfe..e49082432061f2 100644 --- a/src/sentry/reprocessing2.py +++ b/src/sentry/reprocessing2.py @@ -315,7 +315,7 @@ def _send_delete_old_primary_hash_messages( def buffered_delete_old_primary_hash( project_id: int, group_id: int, - event_id: int | None = None, + event_id: str | None = None, datetime: datetime | None = None, old_primary_hash: str | None = None, current_primary_hash: str | None = None, diff --git a/src/sentry/tasks/post_process.py b/src/sentry/tasks/post_process.py index ab5183e3689427..a1d130381b7c33 100644 --- a/src/sentry/tasks/post_process.py +++ b/src/sentry/tasks/post_process.py @@ -512,7 +512,8 @@ def post_process_group( cache_key, group_id=None, occurrence_id: str | None = None, - project_id: int | None = None, + *, + project_id: int, **kwargs, ): """ diff --git a/tests/relay_integration/test_sdk.py b/tests/relay_integration/test_sdk.py index a5f411743dded4..7a83ed6fc7a7c5 100644 --- a/tests/relay_integration/test_sdk.py +++ b/tests/relay_integration/test_sdk.py @@ -43,6 +43,7 @@ def post_event_with_sdk(settings, relay_server, wait_for_ingest_consumer): def inner(*args, **kwargs): event_id = sentry_sdk.capture_event(*args, **kwargs) + assert event_id is not None sentry_sdk.flush() with sentry_sdk.scope.use_scope(current_scope):