File tree Expand file tree Collapse file tree
src/sentry/seer/code_review Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff 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
4445class 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 :
You can’t perform that action at this time.
0 commit comments