Skip to content

feat(code_review): Call new endpoints#109956

Merged
armenzg merged 4 commits intomasterfrom
call_correct_endpoint
Mar 10, 2026
Merged

feat(code_review): Call new endpoints#109956
armenzg merged 4 commits intomasterfrom
call_correct_endpoint

Conversation

@armenzg
Copy link
Copy Markdown
Member

@armenzg armenzg commented Mar 5, 2026

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.

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.
@armenzg armenzg self-assigned this Mar 5, 2026
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 5, 2026

# Coding Workflows
register(
"coding_workflows.code_review.github.check_run.rerun.enabled",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Once the change sticks, we will remove this.

@armenzg armenzg marked this pull request as ready for review March 5, 2026 18:06
@armenzg armenzg requested a review from a team as a code owner March 5, 2026 18:06
Comment on lines +75 to +77
# 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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can do it as a follow-up. I want to get this rolled out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will see if I can handle it right now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@armenzg armenzg requested review from a team and vaind March 10, 2026 12:40
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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.

Create PR

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",

@armenzg armenzg enabled auto-merge (squash) March 10, 2026 15:27
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"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Image Image

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"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Image

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"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Image

@armenzg armenzg merged commit 239332f into master Mar 10, 2026
56 checks passed
@armenzg armenzg deleted the call_correct_endpoint branch March 10, 2026 15:51
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants