-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Migrate Seer handlers for code reviews to SCM listeners #112349
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| from sentry.rules import rules | ||
|
|
||
| from .actions.create_ticket import GitHubCreateTicketAction | ||
| from .handlers import GithubActionHandler # noqa: F401,F403 | ||
|
|
||
| rules.add(GitHubCreateTicketAction) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,9 +59,6 @@ | |
| from sentry.scm.private.stream_producer import produce_event_to_scm_stream | ||
| from sentry.seer.autofix.webhooks import handle_github_pr_webhook_for_autofix | ||
| from sentry.seer.code_review.contributor_seats import track_contributor_seat | ||
| from sentry.seer.code_review.webhooks.handlers import ( | ||
| handle_webhook_event as code_review_handle_webhook_event, | ||
| ) | ||
| from sentry.shared_integrations.exceptions import ApiError | ||
| from sentry.silo.base import SiloMode | ||
| from sentry.users.services.user.service import user_service | ||
|
|
@@ -847,10 +844,7 @@ class PullRequestEventWebhook(GitHubWebhook): | |
| """https://developer.github.com/v3/activity/events/types/#pullrequestevent""" | ||
|
|
||
| EVENT_TYPE = IntegrationWebhookEventType.MERGE_REQUEST | ||
| WEBHOOK_EVENT_PROCESSORS = ( | ||
| _handle_pr_webhook_for_autofix_processor, | ||
| code_review_handle_webhook_event, | ||
| ) | ||
| WEBHOOK_EVENT_PROCESSORS = (_handle_pr_webhook_for_autofix_processor,) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Seer code review functionality will silently fail upon deployment because the new async processing path is gated by a feature flag that is disabled by default. Suggested FixTo prevent a silent outage, either remove the feature flag gating Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This statement is true, and was anticipated in bold font in the PR description. |
||
|
|
||
| def _handle( | ||
| self, | ||
|
|
@@ -976,10 +970,7 @@ class CheckRunEventWebhook(GitHubWebhook): | |
| """ | ||
|
|
||
| EVENT_TYPE = IntegrationWebhookEventType.CI_CHECK | ||
| WEBHOOK_EVENT_PROCESSORS = ( | ||
| code_review_handle_webhook_event, | ||
| handle_preprod_check_run_event, | ||
| ) | ||
| WEBHOOK_EVENT_PROCESSORS = (handle_preprod_check_run_event,) | ||
|
|
||
|
|
||
| class IssueCommentEventWebhook(GitHubWebhook): | ||
|
|
@@ -989,7 +980,7 @@ class IssueCommentEventWebhook(GitHubWebhook): | |
| """ | ||
|
|
||
| EVENT_TYPE = IntegrationWebhookEventType.ISSUE_COMMENT | ||
| WEBHOOK_EVENT_PROCESSORS = (code_review_handle_webhook_event,) | ||
| WEBHOOK_EVENT_PROCESSORS = () | ||
|
|
||
|
|
||
| @all_silo_endpoint | ||
|
|
@@ -1150,7 +1141,7 @@ def handle(self, request: HttpRequest) -> HttpResponse: | |
| { | ||
| "event_type_hint": request.headers.get(GITHUB_WEBHOOK_TYPE_HEADER_KEY), | ||
| "event": request.body.decode("utf-8"), | ||
| "extra": {}, | ||
| "extra": {"github_delivery_id": github_delivery_id}, | ||
| "received_at": int(time.time()), | ||
| "sentry_meta": None, | ||
| "type": IntegrationProviderSlug.GITHUB.value, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +0,0 @@ | ||
| """ | ||
| This module provides a single entry point for the webhook handler to handle webhook events. | ||
| """ | ||
|
|
||
| from .handlers import handle_webhook_event as code_review_webhook_processor | ||
|
|
||
| __all__ = ["code_review_webhook_processor"] | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Action handler registration moved to unreliable import location
High Severity
The
GithubActionHandlerside-effect import was moved fromsentry/integrations/github/__init__.pytosentry_plugins/github/client.py. This new location is only loaded on-demand, preventing the handler from reliably registering during startup. Consequently, GitHub workflow engine actions, like ticket creation, will not function.Additional Locations (1)
src/sentry_plugins/github/client.py#L5-L6Reviewed by Cursor Bugbot for commit 2f4ffa0. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement is concerning, but importing
.integrations.github.handlersin__init__.pyis incompatible with importing the listeners statically in.../scm/stream.py. This all boils down tosentry/integrations/jira/client.pycallingabsolute_urlat module level, which requiresinitialize_appto have been called.I checked the original stacktrace when
action_handler_registry.registerwas called forGithubActionHandlerand made sure that it's still registered "during startup".It might be worth defining "during startup": I'm talking about the startup of the backend web server. If
GithubActionHandlershould be registered to theaction_handler_registryfor other processes, their startup sequence must indeed be modified in a similar way.The compromise I chose can be revisited by a human with a more effective brain than mine.