Skip to content

Commit b976b8d

Browse files
committed
pr review feedback
1 parent 15a0f3f commit b976b8d

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/sentry/seer/code_review/contributor_seats.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ def seed_contributor(
9090
user_id: str | int,
9191
user_username: str,
9292
) -> OrganizationContributors:
93+
"""
94+
Create the OrganizationContributors row without incrementing the number
95+
of actions.
96+
97+
Seeding happens upstream when the PR is created; the action is incremented
98+
separately only after the PR clears the code-review preflight check and
99+
other checks on the webhook's properties.
100+
"""
93101
contributor, _ = OrganizationContributors.objects.get_or_create(
94102
organization_id=organization.id,
95103
integration_id=integration_id,

src/sentry/seer/code_review/webhooks/pull_request.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Log(enum.StrEnum):
3939
MISSING_PULL_REQUEST = "github.webhook.pull_request.missing-pull-request"
4040
MISSING_ACTION = "github.webhook.pull_request.missing-action"
4141
UNSUPPORTED_ACTION = "github.webhook.pull_request.unsupported-action"
42+
MISSING_AUTHOR_ID = "github.webhook.pull_request.missing-author-id"
4243

4344

4445
class PullRequestAction(enum.StrEnum):
@@ -174,6 +175,17 @@ def handle_pull_request_event(
174175
user_id=author_id,
175176
provider="github",
176177
)
178+
else:
179+
# A missing user id means we can't identify which contributor's actions to increment.
180+
# This should never happen.
181+
logger.warning(
182+
Log.MISSING_AUTHOR_ID.value,
183+
extra={
184+
"organization_id": organization.id,
185+
"repo_id": repo.id,
186+
"integration_id": integration.id,
187+
},
188+
)
177189

178190
pr_number = pull_request.get("number")
179191
if pr_number and action in ACTIONS_ELIGIBLE_FOR_EYES_REACTION:

0 commit comments

Comments
 (0)