Skip to content

ci(workflow): Skip PR review reminders when already approved - #20629

Merged
JPeer264 merged 1 commit into
developfrom
jp/nudge-pr-skip-if-approved
May 4, 2026
Merged

ci(workflow): Skip PR review reminders when already approved#20629
JPeer264 merged 1 commit into
developfrom
jp/nudge-pr-skip-if-approved

Conversation

@JPeer264

Copy link
Copy Markdown
Member

Only allow PR nudges when the PR has not yet been approved.

If a PR already has at least one approval, there's no need to nudge
the remaining requested reviewers.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@JPeer264
JPeer264 requested review from chargome and mydeaMay 4, 2026 08:06
@JPeer264JPeer264 self-assigned this May 4, 2026
@JPeer264
JPeer264 enabled auto-merge (squash) May 4, 2026 08:07

@cursorcursorBot left a comment

Copy link
Copy Markdown

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c2c0bec. Configure here.

pull_number: pr.number,
per_page: 100,
});
const hasApproval = reviews.some(r => r.state === 'APPROVED');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale approval check ignores superseding reviews

Medium Severity

The reviews.some(r => r.state === 'APPROVED') check looks at all review objects ever submitted on the PR, not just the latest from each reviewer. GitHub's listReviews API preserves every review chronologically — if a reviewer first approves and later submits a "Changes Requested" review, both objects are retained with their original states. This means the check finds the stale APPROVED review and incorrectly skips the reminder, even though no current approval exists. The fix would be to consider only each reviewer's most recent review when determining approval status.

Fix in CursorFix in Web

Reviewed by Cursor Bugbot for commit c2c0bec. Configure here.

Comment on lines +184 to +185
const hasApproval = reviews.some(r => r.state === 'APPROVED');
if (hasApproval) continue;

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.

Bug: The check for existing approvals (hasApproval) doesn't differentiate between current and stale approvals, causing reminders to be skipped for reviewers who are re-requested after new commits are pushed.
Severity: MEDIUM

Suggested Fix

To fix this, the logic should not rely solely on the presence of an APPROVED review. It should correlate reviews with the latest commit hash or consider the review submission timestamp relative to the last commit. Alternatively, filter out reviews that predate the most recent commit on the PR before checking for an APPROVED state. This ensures that only approvals on the current version of the code are considered.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: scripts/pr-review-reminder.mjs#L184-L185
Potential issue: The script determines if a PR has an approval by checking if
`reviews.some(r => r.state === 'APPROVED')`. This logic is flawed because it doesn't
account for stale approvals. On repositories without the "Dismiss stale pull request
approvals" setting, if new commits are pushed after an approval and the same reviewer is
re-requested, their old `APPROVED` review persists. The script will incorrectly detect
this as a current approval, set `hasApproval` to `true`, and skip sending a reminder,
effectively silencing reminders for that reviewer indefinitely.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Good bot. But in our workflow that is super rare. To keep it simple I'll leave it as is

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser26.16 kB--
@sentry/browser - with treeshaking flags24.63 kB--
@sentry/browser (incl. Tracing)44.13 kB--
@sentry/browser (incl. Tracing + Span Streaming)46.34 kB--
@sentry/browser (incl. Tracing, Profiling)49.08 kB--
@sentry/browser (incl. Tracing, Replay)83.48 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags72.96 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)88.15 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)100.8 kB--
@sentry/browser (incl. Feedback)43.4 kB--
@sentry/browser (incl. sendFeedback)30.96 kB--
@sentry/browser (incl. FeedbackAsync)36.14 kB--
@sentry/browser (incl. Metrics)27.44 kB--
@sentry/browser (incl. Logs)27.59 kB--
@sentry/browser (incl. Metrics & Logs)28.28 kB--
@sentry/react27.9 kB--
@sentry/react (incl. Tracing)46.36 kB--
@sentry/vue31.03 kB--
@sentry/vue (incl. Tracing)45.96 kB--
@sentry/svelte26.18 kB--
CDN Bundle28.85 kB--
CDN Bundle (incl. Tracing)46.91 kB--
CDN Bundle (incl. Logs, Metrics)30.27 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)48.03 kB--
CDN Bundle (incl. Replay, Logs, Metrics)69.35 kB--
CDN Bundle (incl. Tracing, Replay)84.07 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)85.14 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)89.86 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)90.96 kB--
CDN Bundle - uncompressed84.55 kB--
CDN Bundle (incl. Tracing) - uncompressed140.16 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed88.75 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed143.62 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed212.71 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed257.96 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed261.41 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed271.66 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed275.1 kB--
@sentry/nextjs (client)48.85 kB--
@sentry/sveltekit (client)44.58 kB--
@sentry/node-core59.06 kB+0.02%+10 B 🔺
@sentry/node170.35 kB+0.01%+12 B 🔺
@sentry/node - without tracing96.92 kB+0.02%+10 B 🔺
@sentry/aws-serverless113.78 kB+0.03%+31 B 🔺
@sentry/cloudflare (withSentry) - minified164.96 kB--
@sentry/cloudflare (withSentry)417.1 kB--

View base workflow run

@JPeer264
JPeer264 merged commit 9680821 into developMay 4, 2026
40 checks passed
@JPeer264
JPeer264 deleted the jp/nudge-pr-skip-if-approved branch May 4, 2026 08:17
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@JPeer264@chargome