feat(code-review): Add option to skip code review for excluded PR authors#110101
feat(code-review): Add option to skip code review for excluded PR authors#110101
Conversation
…hors Register `seer.code-review.excluded-pr-author-logins` option to allow configuring a list of PR author logins (e.g., dependabot[bot]) to skip code review for. The check uses contributor.alias and applies to all org types. Co-Authored-By: Claude Opus 4.6 <[email protected]>
72579be to
1c33b20
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| if not self._is_seat_based_seer_plan_org and ( | ||
| self._is_code_review_beta_org or self._is_legacy_usage_based_seer_plan_org | ||
| ): | ||
| return None |
There was a problem hiding this comment.
Beta/legacy orgs now denied when contributor info missing
High Severity
Moving the beta/legacy org exemption after the contributor lookup introduces a regression. Previously, beta/legacy orgs bypassed all billing checks (returning None immediately). Now they'll be denied with BILLING_MISSING_CONTRIBUTOR_INFO if integration_id or pr_author_external_id is None, or with ORG_CONTRIBUTOR_NOT_FOUND if no contributor record exists. The intent was only to add the excluded-author check for all org types, but the reordering also removed the exemption from unrelated failure modes that beta/legacy orgs previously never hit.
There was a problem hiding this comment.
Also curious about the reordering here @srest2021, should we have just put the new condition you added as the first check?
There was a problem hiding this comment.
The thing is we need the integration id to get the contributor, which has the login. I can't see any solution other than just letting authors in beta orgs bypass the check :(
There was a problem hiding this comment.
When is integration id missing?
There was a problem hiding this comment.
It doesn't look like we have any instances of this happening during the last month https://app.datadoghq.com/dashboard/6x2-jgc-kiz/code-review?fromUser=true&refresh_mode=paused&from_ts=1770429006956&to_ts=1772848206956&live=false&tile_focus=6133593483676046
There was a problem hiding this comment.
@cursor help me by clarifying what's this about
There was a problem hiding this comment.
Based on my analysis of the code and PR discussion, here's what's happening:
The Issue
Original behavior (before this PR):
The _check_billing() method had beta/legacy orgs exit early at the very beginning:
def _check_billing(self):
# Beta/legacy exemption was FIRST
if beta_or_legacy_org:
return None # Skip all billing checks
# These checks only ran for seat-based orgs
if integration_id is None or pr_author_external_id is None:
return BILLING_MISSING_CONTRIBUTOR_INFO
contributor = get_contributor(...) # Might not existCurrent behavior (after this PR):
The beta/legacy exemption was moved to AFTER the contributor lookup:
def _check_billing(self):
# Now checks integration_id FIRST for all orgs
if integration_id is None or pr_author_external_id is None:
return BILLING_MISSING_CONTRIBUTOR_INFO # ❌ Beta orgs now hit this
contributor = get_contributor(...) # ❌ Beta orgs now hit DoesNotExist
if contributor.alias in excluded_logins: # The new feature
return PR_AUTHOR_EXCLUDED
# Beta/legacy exemption now happens AFTER contributor lookup
if beta_or_legacy_org:
return NoneWhy It Was Reordered
The PR author (@srest2021) needs the contributor.alias to check if the PR author is excluded (e.g., dependabot). To get the contributor, they need integration_id and pr_author_external_id. So they had to move the beta/legacy exemption after the contributor lookup.
The Risk
Beta/legacy orgs will now be denied code review if:
integration_idis missing → ReturnsBILLING_MISSING_CONTRIBUTOR_INFOpr_author_external_idis missing → ReturnsBILLING_MISSING_CONTRIBUTOR_INFO- No contributor record exists → Returns
ORG_CONTRIBUTOR_NOT_FOUND
Previously, beta/legacy orgs bypassed these checks entirely.
Why It Might Be Fine
According to the Datadog dashboard that @srest2021 shared, there haven't been any instances of missing integration_id in the last month. If these fields are always present in practice, the regression won't manifest.
Recommendation
Since there's no evidence of missing data in production, the current implementation is probably fine. However, to be defensive, you could consider adding an early exemption for beta/legacy orgs that don't have the required contributor info, essentially treating them like excluded authors.
There was a problem hiding this comment.
In the caller of CodeReviewPreflightService, we return early if integration is None, and we can get the PR author's external id from multiple spots in the webhook. If I had to pick a condition to be worried about, it would be a missing contributor row.
There was a problem hiding this comment.
In theory the organization contributors always get created in here when they create new PRs, so in theory we should have rows for all expected OrganizationContributors. So should be good to go
| if not self._is_seat_based_seer_plan_org and ( | ||
| self._is_code_review_beta_org or self._is_legacy_usage_based_seer_plan_org | ||
| ): | ||
| return None |
There was a problem hiding this comment.
In theory the organization contributors always get created in here when they create new PRs, so in theory we should have rows for all expected OrganizationContributors. So should be good to go




Relates to CW-972
options-automator followup: https://github.com/getsentry/sentry-options-automator/pull/6728
Register
seer.code-review.excluded-pr-author-loginsoption to allow configuring a list of PR author logins (e.g., dependabot[bot]) to skip code review for. The check uses contributor.alias and applies to all org types, including beta and legacy orgs.