Skip to content

fix(code-review): Check if org has disabled default code review triggers#106430

Merged
suejung-sentry merged 8 commits intomasterfrom
sshin/fix-trigger
Jan 19, 2026
Merged

fix(code-review): Check if org has disabled default code review triggers#106430
suejung-sentry merged 8 commits intomasterfrom
sshin/fix-trigger

Conversation

@suejung-sentry
Copy link
Contributor

@suejung-sentry suejung-sentry commented Jan 16, 2026

Fix trigger check to look within settings for seat-based-seer orgs (post GA)

Closes https://linear.app/getsentry/issue/CW-311/add-check-for-the-trigger-enabled-downstream-of-preflight

@suejung-sentry suejung-sentry self-assigned this Jan 16, 2026
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 16, 2026
@linear
Copy link

linear bot commented Jan 16, 2026

organization=organization,
repo=repo,
integration=integration,
settings=preflight.settings,
Copy link
Member

Choose a reason for hiding this comment

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

You can import this within pull_request rather than passing it down.

Copy link
Contributor Author

@suejung-sentry suejung-sentry Jan 17, 2026

Choose a reason for hiding this comment

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

Could you clarify what you mean there?
The settings depend on org type logic that's already computed in the preflight check, and duplicating that in pull_request.py seems worse than passing it as a parameter. Also making it explicit instead of part of the kwargs seems better for type hints. So probably missing what you mean on that.

In theory "settings" can grow based on how our product's configurability grows. Right now we have pretty coarse controls of just the repo enabled or not and upon which triggers it runs on. But in the future other things we considered are like what sensitivity level of reviews you want, or what "flavor" of code review (a general code reviewer, or one more focused on bugs, or perhaps one day one more focused on performance bugs). All that is meant to be collected into this one spot of the settings object. It's true that today it's only read on pull_request events, but in my time working on this it's been asked to be added to other ones here and there (our current state only has it in pull_request tho, correct)

return CodeReviewPreflightResult(allowed=True, settings=self._repo_settings)
settings: CodeReviewSettings | None = self._repo_settings
if self._is_code_review_beta_org() or self._is_legacy_usage_based_seer_plan_org():
settings = DEFAULT_ENABLED_CODE_REVIEW_SETTINGS
Copy link
Member

Choose a reason for hiding this comment

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

You don't need yet another data structure. You could do this:

settings: CodeReviewSettings | None = self._repo_settings
if self._is_code_review_beta_org() or self._is_legacy_usage_based_seer_plan_org():
    settings = CodeReviewSettings(
        enabled=True,
        triggers=[
            CodeReviewTrigger.ON_NEW_COMMIT,
            CodeReviewTrigger.ON_READY_FOR_REVIEW,
        ],
    )

Copy link
Contributor

Choose a reason for hiding this comment

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

I kind of like having an explicit const denote what the default settings are. Alternatively can do what you suggested but add a comment denoting that is the default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I liked the explicit const too but fine with this too. Moved it down and added a comment denoting it is a default


if self._triggers:
trigger_values = [t.value for t in self._triggers]
self.create_repository_settings(
Copy link
Member

Choose a reason for hiding this comment

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

This should not be happening as part of tests set up. We need to rely on the code to do this for us.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the equivalent of the user picking these options. In the same way we are using test setup for create_repo we to do the same for create_repo_settings. If we want to go crazy we have to call the endpoint to either manually or auto-set this up from way upstream in the onboarding flow just as the user would. Seems outside the scope of what we should be testing here

@suejung-sentry suejung-sentry marked this pull request as ready for review January 19, 2026 06:36
@suejung-sentry suejung-sentry requested a review from a team as a code owner January 19, 2026 06:36
@armenzg armenzg changed the title fix(code-review): Fix trigger check fix(code-review): Evaluate if org has disabled certain code review triggers Jan 19, 2026
@armenzg armenzg changed the title fix(code-review): Evaluate if org has disabled certain code review triggers fix(code-review): Check if org has disabled default code review triggers Jan 19, 2026
Copy link
Member

@armenzg armenzg left a comment

Choose a reason for hiding this comment

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

In order to speed up merging this PR I'm going to approve it.

I'm going to propose some changes but I first need to make sure they make sense.

Copy link
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.

Copy link
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.


self._send_webhook_event(GithubWebhookType.PULL_REQUEST, orjson.dumps(event))

self.mock_seer.assert_called_once()
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests for seat-based orgs missing billing setup

Medium Severity

The new tests for seat-based orgs (seat-based-seer-enabled feature) are missing required billing infrastructure setup. For seat-based orgs, the preflight _check_billing method requires OrganizationContributors to exist and check_seer_quota to pass. Without this setup, tests expecting Seer to be called (test_pull_request_closed_bypasses_trigger_check_post_ga, test_pull_request_opened_works_when_trigger_enabled_post_ga, test_pull_request_ready_for_review_works_when_trigger_enabled_post_ga) will fail due to billing check failure. Tests expecting Seer NOT to be called may pass but for the wrong reason (billing failure instead of trigger check).

Additional Locations (1)

Fix in Cursor Fix in Web

@suejung-sentry suejung-sentry merged commit ec5cdb9 into master Jan 19, 2026
66 checks passed
@suejung-sentry suejung-sentry deleted the sshin/fix-trigger branch January 19, 2026 18:17
BYK pushed a commit that referenced this pull request Jan 19, 2026
…ers (#106430)

Fix trigger check to look within settings for seat-based-seer orgs (post
GA)

Closes
https://linear.app/getsentry/issue/CW-311/add-check-for-the-trigger-enabled-downstream-of-preflight

---------

Co-authored-by: Armen Zambrano G. <44410+armenzg@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 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.

4 participants