Skip to content

Commit ddea878

Browse files
fix check run billing gate
1 parent 1a69e22 commit ddea878

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

fixtures/github.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,7 +3560,7 @@
35603560
"external_id": "4663713",
35613561
"html_url": "https://github.com/test/repo/runs/4"
35623562
},
3563-
"user": {
3563+
"sender": {
35643564
"id": 12345678,
35653565
"login": "test-user"
35663566
}
@@ -3574,7 +3574,7 @@
35743574
"full_name": "getsentry/sentry",
35753575
"html_url": "https://github.com/getsentry/sentry"
35763576
},
3577-
"user": {
3577+
"sender": {
35783578
"id": 12345678,
35793579
"login": "test-user"
35803580
}

src/sentry/seer/code_review/preflight.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
from sentry.models.repository import Repository
1010
from sentry.models.repositorysettings import CodeReviewSettings, RepositorySettings
1111

12-
from .billing import passes_code_review_billing_check
13-
1412
DenialReason = str | None
1513

1614

@@ -91,6 +89,8 @@ def _check_repo_feature_enablement(self) -> DenialReason:
9189
return "repo_code_review_disabled"
9290

9391
def _check_billing(self) -> DenialReason:
92+
# TODO: Once we're ready to actually gate billing (when it's time for GA), uncomment this
93+
"""
9494
if self.integration_id is None or self.pr_author_external_id is None:
9595
return "billing_missing_contributor_info"
9696
@@ -101,6 +101,7 @@ def _check_billing(self) -> DenialReason:
101101
)
102102
if not billing_ok:
103103
return "billing_quota_exceeded"
104+
"""
104105

105106
return None
106107

src/sentry/seer/code_review/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,8 @@ def get_pr_author_id(event: Mapping[str, Any]) -> str | None:
220220
if (user_id := event.get("user", {}).get("id")) is not None:
221221
return str(user_id)
222222

223+
# Check sender.id (for check_run events). Sender is the user who triggered the event
224+
if (user_id := event.get("sender", {}).get("id")) is not None:
225+
return str(user_id)
226+
223227
return None

tests/sentry/seer/code_review/test_preflight.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from unittest.mock import MagicMock, patch
22

33
from sentry.models.organizationcontributors import OrganizationContributors
4-
from sentry.models.repositorysettings import CodeReviewTrigger, RepositorySettings
4+
from sentry.models.repositorysettings import RepositorySettings
55
from sentry.seer.code_review.preflight import CodeReviewPreflightService
66
from sentry.silo.base import SiloMode
77
from sentry.testutils.cases import TestCase
@@ -172,6 +172,9 @@ def test_allowed_when_seat_based_org_has_repo_settings_enabled(
172172
# Billing tests
173173
# -------------------------------------------------------------------------
174174

175+
176+
# TODO: Uncomment these billing tests once we're ready to actually gate billing (when it's time for GA)
177+
"""
175178
@with_feature(["organizations:gen-ai-features", "organizations:code-review-beta"])
176179
def test_denied_when_missing_integration_id(self) -> None:
177180
self.organization.update_option("sentry:enable_pr_review_test_generation", True)
@@ -284,3 +287,4 @@ def test_returns_none_settings_for_beta_org_without_repo_settings(
284287
285288
assert result.allowed is True
286289
assert result.settings is None
290+
"""

0 commit comments

Comments
 (0)