Skip to content

feat(preprod): Tie approvals to the result they approved - #133319

Open
sentry-junior[bot] wants to merge 4 commits into
masterfrom
nicohinderling/eme-1371-make-approvals-cover-only-the-result
Open

sentry-junior[bot] wants to merge 4 commits into
masterfrom
nicohinderling/eme-1371-make-approvals-cover-only-the-result

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

An approval used to cover the whole build, so a result that changed after approval (a late snapshot base, a rerun or a size base that completes) still passed, and could seed auto-approval. Each new approval now saves the result it covers in extras. It counts only while that result matches, in the status checks, get_size_status, auto-approval, the "Already approved" checks and the build and snapshot pages. For size, the base is part of the result only when a diff rule is configured. Approvals made before this change keep counting. Refs EME-1371

Each new approval saves the snapshot comparison or size analysis it covers, and only counts while that result is unchanged.

Refs EME-1371

Co-Authored-By: Nico Hinderling <9902528+NicoHinderling@users.noreply.github.com>
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
scraps Ignored Ignored Preview Dec 3, 2026 1:32am UTC

Request Review

@linear-code

linear-code Bot commented Dec 2, 2026

Copy link
Copy Markdown

EME-1371

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

decision-model-linter

api

src/sentry/preprod/vcs/webhooks/github_check_run.py

  • warn readsWebhookPayloadOutsideSerializer = TRUE (0.77): Third-party webhook payloads should be validated with a serializer or typed schema before their fields are read. This file reads fields directly from the incoming payload.

decision-model-linter: 44 calls on 9 files, 113,359 input tokens, $0.0048, model typesafe/jev-1.13-20260917

Sentry's build and snapshot pages counted any approval, so after the
result changed they still showed it as approved and hid the Approve
action. Size approvals also reset whenever the base changed, even when
no rule compares against the base. Auto-approval now reads the sibling's
newest comparison, the same one the status check uses.

Refs EME-1371
@NicoHinderling
NicoHinderling marked this pull request as ready for review December 2, 2026 23:48
@NicoHinderling
NicoHinderling requested a review from a team as a code owner December 2, 2026 23:48
from sentry.models.commitcomparison import CommitComparison
from sentry.models.project import Project
from sentry.preprod.analytics import PreprodStatusCheckTriggeredRulePostedEvent
from sentry.preprod.approvals import approval_matches, size_approval_result

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.

Size approval matching uses caller rules, so PR comments drop valid approvals

Approvals store size_approval_result with status-check rules, but evaluate_size_and_format_messages rebuilds the result with the caller-supplied rules. PR comments pass preprod_size_pr_comments_rules, so a differing diff-rule config makes base_size_analysis disagree and a still-valid size approval is ignored.

Evidence
  • get_approval_result() always calls size_approval_result(..., get_status_check_rules(artifact.project)), so saved base_size_analysis depends only on status-check rules (absolute_diff/relative_diff).
  • The new matching path in evaluate_size_and_format_messages calls size_approval_result(..., rules) with whatever list the caller passed, then approval_matches requires exact equality.
  • create_preprod_size_pr_comment_task loads rules via option_key=sentry:preprod_size_pr_comments_rules, which is independent of status-check rules.
  • If only one of those rule sets has a diff measurement, one side gets base_size_analysis: None and the other a metric list; matching fails and the approval is omitted from approvals_map, so PR comments still treat the build as action-required.

Identified by Warden · code-review · ZPZ-N8K

…pprovals

Build details now look up the size approval result only for builds that
have a size approval, so list endpoints no longer run extra queries per
build. Size approval matching always uses the status-check rules, so the
PR comment's own rule set can't make a valid approval look stale.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant