feat(code_review): Call new endpoints#109956
Conversation
We added two new endpoints in Seer to replace the `overwatch-request` endpoint. This change makes code review events to go to the two new endpoints instead of the old one.
|
|
||
| # Coding Workflows | ||
| register( | ||
| "coding_workflows.code_review.github.check_run.rerun.enabled", |
There was a problem hiding this comment.
Orthogonal: This is an old option we need to remove.
| class SeerEndpoint(StrEnum): | ||
| # https://github.com/getsentry/seer/blob/main/src/seer/routes/automation_request.py#L57 | ||
| # Legacy; used when coding_workflows.code_review.seer.use_new_endpoints is False | ||
| OVERWATCH_REQUEST = "/v1/automation/overwatch-request" |
There was a problem hiding this comment.
Once the change sticks, we will remove this.
src/sentry/seer/code_review/utils.py
Outdated
| # New dedicated endpoints (used when use_new_endpoints is True) | ||
| CODE_REVIEW_REVIEW_REQUEST = "/v1/automation/code_review/review-request" | ||
| CODE_REVIEW_PR_CLOSED = "/v1/automation/code_review/pr-closed" |
There was a problem hiding this comment.
Do we need the "automation" infix? This relates to a recent rename in repo where we moved src/seer/automation/codegan to src/seer/code_review. I realize it's not a 1-to-1 mapping but it looks like the original logic here was actually based on the path in the filesystem. Do you think it would be beneficial to move the API endpoint as well?
There was a problem hiding this comment.
I can do it as a follow-up. I want to get this rolled out.
There was a problem hiding this comment.
I will see if I can handle it right now.
There was a problem hiding this comment.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Rerun endpoint path change not gated by feature flag
- Added legacy rerun endpoint and gated the path change behind coding_workflows.code_review.seer.use_new_endpoints option to prevent failures before Seer deployment.
Or push these changes by commenting:
@cursor push 4d246c290f
Preview (4d246c290f)
diff --git a/src/sentry/seer/code_review/utils.py b/src/sentry/seer/code_review/utils.py
--- a/src/sentry/seer/code_review/utils.py
+++ b/src/sentry/seer/code_review/utils.py
@@ -70,9 +70,10 @@
class SeerEndpoint(StrEnum):
# Legacy; used when coding_workflows.code_review.seer.use_new_endpoints is False
OVERWATCH_REQUEST = "/v1/automation/overwatch-request"
+ PR_REVIEW_RERUN_LEGACY = "/v1/automation/codegen/pr-review/rerun"
+ # New dedicated endpoints (used when use_new_endpoints is True)
# https://github.com/getsentry/seer/blob/main/src/seer/routes/codegen.py
PR_REVIEW_RERUN = "/v1/code_review/check/rerun"
- # New dedicated endpoints (used when use_new_endpoints is True)
CODE_REVIEW_REVIEW_REQUEST = "/v1/code_review/review-request"
CODE_REVIEW_PR_CLOSED = "/v1/code_review/pr-closed"
@@ -83,10 +84,13 @@
When coding_workflows.code_review.seer.use_new_endpoints is False, PR/issue_comment
events use the legacy overwatch-request endpoint. When True, they use the dedicated
- review-request or pr-closed endpoints. CHECK_RUN always uses the rerun endpoint.
+ review-request or pr-closed endpoints. CHECK_RUN uses the legacy or new rerun endpoint
+ based on the same option.
"""
if github_event == GithubWebhookType.CHECK_RUN.value:
- return SeerEndpoint.PR_REVIEW_RERUN.value
+ if options.get("coding_workflows.code_review.seer.use_new_endpoints"):
+ return SeerEndpoint.PR_REVIEW_RERUN.value
+ return SeerEndpoint.PR_REVIEW_RERUN_LEGACY.value
if not options.get("coding_workflows.code_review.seer.use_new_endpoints"):
return SeerEndpoint.OVERWATCH_REQUEST.value
if payload.get("request_type") == "pr-closed":
diff --git a/tests/sentry/seer/code_review/test_webhooks.py b/tests/sentry/seer/code_review/test_webhooks.py
--- a/tests/sentry/seer/code_review/test_webhooks.py
+++ b/tests/sentry/seer/code_review/test_webhooks.py
@@ -421,7 +421,7 @@
@patch("sentry.seer.code_review.utils.make_signed_seer_api_request")
def test_check_run_and_pr_events_processed_separately(self, mock_request: MagicMock) -> None:
- """Test that CHECK_RUN uses rerun endpoint; PR events use overwatch-request when option off."""
+ """Test that CHECK_RUN uses legacy rerun endpoint; PR events use overwatch-request when option off."""
mock_request.return_value = self._mock_response(200, b"{}")
process_github_webhook_event._func(
@@ -432,7 +432,7 @@
assert mock_request.call_count == 1
check_run_call = mock_request.call_args
- assert check_run_call[1]["path"] == "/v1/code_review/check/rerun"
+ assert check_run_call[1]["path"] == "/v1/automation/codegen/pr-review/rerun"
mock_request.reset_mock()
@@ -478,9 +478,21 @@
@patch("sentry.seer.code_review.utils.make_signed_seer_api_request")
def test_pr_event_uses_new_endpoints_when_option_enabled(self, mock_request: MagicMock) -> None:
- """Test that with use_new_endpoints option, PR review uses review-request and pr-closed uses pr-closed."""
+ """Test that with use_new_endpoints option, all events use new endpoints."""
mock_request.return_value = self._mock_response(200, b"{}")
+ with override_options({"coding_workflows.code_review.seer.use_new_endpoints": True}):
+ process_github_webhook_event._func(
+ github_event=GithubWebhookType.CHECK_RUN,
+ event_payload={"original_run_id": self.original_run_id},
+ enqueued_at_str=self.enqueued_at_str,
+ )
+
+ assert mock_request.call_count == 1
+ assert mock_request.call_args[1]["path"] == "/v1/code_review/check/rerun"
+
+ mock_request.reset_mock()
+
pr_review_payload = {
"request_type": "pr-review",
"external_owner_id": "456",| OVERWATCH_REQUEST = "/v1/automation/overwatch-request" | ||
| # https://github.com/getsentry/seer/blob/main/src/seer/routes/codegen.py | ||
| PR_REVIEW_RERUN = "/v1/automation/codegen/pr-review/rerun" | ||
| PR_REVIEW_RERUN = "/v1/code_review/check/rerun" |
| PR_REVIEW_RERUN = "/v1/automation/codegen/pr-review/rerun" | ||
| PR_REVIEW_RERUN = "/v1/code_review/check/rerun" | ||
| # New dedicated endpoints (used when use_new_endpoints is True) | ||
| CODE_REVIEW_REVIEW_REQUEST = "/v1/code_review/review-request" |
| PR_REVIEW_RERUN = "/v1/code_review/check/rerun" | ||
| # New dedicated endpoints (used when use_new_endpoints is True) | ||
| CODE_REVIEW_REVIEW_REQUEST = "/v1/code_review/review-request" | ||
| CODE_REVIEW_PR_CLOSED = "/v1/code_review/pr-closed" |



We added two new endpoints in Seer to replace the
overwatch-requestendpoint.This change makes code review events to go to the two new endpoints instead of the old one.