Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: fix typing for event_id (it is str) #72718

Merged
merged 1 commit into from
Jun 13, 2024
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
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/group_ai_autofix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions src/sentry/eventstore/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/eventstore/reprocessing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/eventstore/reprocessing/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/sentry/eventstore/snuba/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/issues/related/trace_connected.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@armenzg is going to handle the api endpoint doing the validation itself instead of here so this int(...) call should go away eventually (and the extra_args would probably become a TypedDict or normal parameters)

# 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
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/reprocessing2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/tasks/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/relay_integration/test_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions tests/sentry/mail/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def test_full_integration(self):
is_new_group_environment=False,
cache_key=write_event_to_cache(event),
group_id=event.group_id,
project_id=self.project.id,
)

assert len(mail.outbox) == 1
Expand Down Expand Up @@ -199,6 +200,7 @@ def test_full_integration_fallthrough(self):
is_new_group_environment=False,
cache_key=write_event_to_cache(event),
group_id=event.group_id,
project_id=self.project.id,
)

assert len(mail.outbox) == 1
Expand Down Expand Up @@ -235,6 +237,7 @@ def test_full_integration_fallthrough_not_provided(self):
is_new_group_environment=False,
cache_key=write_event_to_cache(event),
group_id=event.group_id,
project_id=self.project.id,
)

# See that the ActiveMembers default results in notifications still being sent
Expand Down Expand Up @@ -318,6 +321,7 @@ def test_hack_mail_workflow(self):
is_new_group_environment=False,
cache_key=write_event_to_cache(event),
group_id=event.group_id,
project_id=self.project.id,
)

assert len(mail.outbox) == 3
Expand Down
1 change: 1 addition & 0 deletions tests/sentry/notifications/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def test_sends_issue_notification(self, record_analytics):
is_new_group_environment=True,
group_id=event.group_id,
cache_key=cache_key,
project_id=self.project.id,
)

msg = mail.outbox[0]
Expand Down
2 changes: 2 additions & 0 deletions tests/sentry/tasks/test_post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,7 @@ def test_process_transaction_event_with_no_group(
cache_key=cache_key,
group_id=None,
group_states=None,
project_id=self.project.id,
)

assert transaction_processed_signal_mock.call_count == 1
Expand Down Expand Up @@ -2651,6 +2652,7 @@ def test_process_transaction_event_clusterer(
is_new_group_environment=False,
cache_key=cache_key,
group_id=None,
project_id=self.project.id,
)

assert mock_store_transaction_name.mock_calls == [
Expand Down
3 changes: 3 additions & 0 deletions tests/sentry/tasks/test_sentry_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def test_group_created_sends_webhook(self, safe_urlopen):
is_new_group_environment=False,
cache_key=write_event_to_cache(event),
group_id=event.group_id,
project_id=self.project.id,
)

((args, kwargs),) = safe_urlopen.call_args_list
Expand Down Expand Up @@ -309,6 +310,7 @@ def test_error_created_sends_webhook(self, safe_urlopen):
is_new_group_environment=False,
cache_key=write_event_to_cache(event),
group_id=event.group_id,
project_id=self.project.id,
)

((args, kwargs),) = safe_urlopen.call_args_list
Expand Down Expand Up @@ -404,6 +406,7 @@ def test_sends_webhooks_to_all_installs(self, safe_urlopen):
is_new_group_environment=False,
cache_key=write_event_to_cache(event),
group_id=event.group_id,
project_id=self.project.id,
)

assert len(safe_urlopen.mock_calls) == 2
Expand Down
Loading