Skip to content

Commit 462daa2

Browse files
fix(code-review): Return enabled config for code review beta cohort (#104899)
For the code review beta cohort, return default config
1 parent eefb8ca commit 462daa2

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/sentry/overwatch/endpoints/overwatch_rpc.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from sentry.api.api_publish_status import ApiPublishStatus
1717
from sentry.api.authentication import AuthenticationSiloLimit, StandardAuthentication
1818
from sentry.api.base import Endpoint, region_silo_endpoint
19-
from sentry.constants import ObjectStatus
19+
from sentry.constants import DEFAULT_CODE_REVIEW_TRIGGERS, ObjectStatus
2020
from sentry.integrations.services.integration import integration_service
2121
from sentry.models.organization import Organization
2222
from sentry.models.repository import Repository
@@ -202,6 +202,15 @@ def get(self, request: Request) -> Response:
202202
)
203203

204204
if repo_settings is None:
205+
organization = Organization.objects.filter(id=sentry_org_id).first()
206+
if organization and features.has("organizations:code-review-beta", organization):
207+
return Response(
208+
{
209+
"enabledCodeReview": True,
210+
"codeReviewTriggers": DEFAULT_CODE_REVIEW_TRIGGERS,
211+
}
212+
)
213+
205214
return Response(
206215
{
207216
"enabledCodeReview": False,

tests/sentry/overwatch/endpoints/test_overwatch_rpc.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from django.urls import reverse
77

8-
from sentry.constants import ObjectStatus
8+
from sentry.constants import DEFAULT_CODE_REVIEW_TRIGGERS, ObjectStatus
99
from sentry.models.repositorysettings import RepositorySettings
1010
from sentry.prevent.models import PreventAIConfiguration
1111
from sentry.prevent.types.config import PREVENT_AI_CONFIG_DEFAULT, PREVENT_AI_CONFIG_DEFAULT_V1
@@ -552,6 +552,30 @@ def test_returns_defaults_when_repo_not_found(self):
552552
assert resp.status_code == 200
553553
assert resp.data == {"enabledCodeReview": False, "codeReviewTriggers": []}
554554

555+
@patch(
556+
"sentry.overwatch.endpoints.overwatch_rpc.settings.OVERWATCH_RPC_SHARED_SECRET",
557+
["test-secret"],
558+
)
559+
def test_returns_enabled_with_default_triggers_when_code_review_beta_flag(self):
560+
org = self.create_organization()
561+
562+
url = reverse("sentry-api-0-code-review-repo-settings")
563+
params = {
564+
"sentryOrgId": str(org.id),
565+
"externalRepoId": "nonexistent-repo-id",
566+
"provider": "integrations:github",
567+
}
568+
auth = self._auth_header_for_get(url, params, "test-secret")
569+
570+
with self.feature({"organizations:code-review-beta": org}):
571+
resp = self.client.get(url, params, HTTP_AUTHORIZATION=auth)
572+
573+
assert resp.status_code == 200
574+
assert resp.data == {
575+
"enabledCodeReview": True,
576+
"codeReviewTriggers": DEFAULT_CODE_REVIEW_TRIGGERS,
577+
}
578+
555579
@patch(
556580
"sentry.overwatch.endpoints.overwatch_rpc.settings.OVERWATCH_RPC_SHARED_SECRET",
557581
["test-secret"],

0 commit comments

Comments
 (0)