Skip to content

feat(code-review): Add option to skip code review for excluded PR authors#110101

Merged
srest2021 merged 3 commits intomasterfrom
srest2021/CW-972
Mar 9, 2026
Merged

feat(code-review): Add option to skip code review for excluded PR authors#110101
srest2021 merged 3 commits intomasterfrom
srest2021/CW-972

Conversation

@srest2021
Copy link
Copy Markdown
Member

@srest2021 srest2021 commented Mar 6, 2026

Relates to CW-972

options-automator followup: https://github.com/getsentry/sentry-options-automator/pull/6728

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, including beta and legacy orgs.

…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]>
@linear-code
Copy link
Copy Markdown

linear-code bot commented Mar 6, 2026

@srest2021 srest2021 changed the title feat(code-review): Add option to skip code review for excluded PR aut… feat(code-review): Add option to skip code review for excluded PR authors Mar 6, 2026
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 6, 2026
@srest2021 srest2021 marked this pull request as ready for review March 6, 2026 18:48
@srest2021 srest2021 requested a review from a team as a code owner March 6, 2026 18:48
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also curious about the reordering here @srest2021, should we have just put the new condition you added as the first check?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is integration id missing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@vaind vaind Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursor help me by clarifying what's this about

Copy link
Copy Markdown
Contributor

@cursor cursor bot Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 exist

Current 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 None

Why 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:

  1. integration_id is missing → Returns BILLING_MISSING_CONTRIBUTOR_INFO
  2. pr_author_external_id is missing → Returns BILLING_MISSING_CONTRIBUTOR_INFO
  3. 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.

Open in Web Open in Cursor 

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as is then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@srest2021 srest2021 merged commit 77ae6fb into master Mar 9, 2026
56 checks passed
@srest2021 srest2021 deleted the srest2021/CW-972 branch March 9, 2026 17:34
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants