Skip to content

fix(github): Sync a PR's next action again after GitHub fails the read - #4316

Merged
BYK merged 4 commits into
junior/pr-action-backfillfrom
junior/pr-action-sync-retry
Nov 25, 2026
Merged

BYK merged 4 commits into
junior/pr-action-backfillfrom
junior/pr-action-sync-retry

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

GitHub returns GraphQL errors with HTTP 200 and no data, mostly RATE_LIMIT when the installation runs out of GraphQL points. These errors failed the webhook next-action sync in bursts (JUNIOR-17B, JUNIOR-1DG). A failed sync keeps the old saved action, and GitHub does not send a failed webhook again. So a quiet pull request kept a stale action and Inbox item until its next webhook.

Now three kinds of failure start a syncPullRequestAction started task that syncs the pull request again: a GraphQL rate limit, a GraphQL error with no type (GitHub's own failure), and a GitHub 5xx. The plugin task queue retries the task with backoff a limited number of times. Nothing polls.

  • After a rate limit, the task waits until the installation's GraphQL limit resets. The reset time comes from GET /rate_limit, which does not count against the limit.
  • Failures whose task would start in the same minute share one task key, so a burst of webhooks gives each pull request one retry.
  • Other failures are logged as before.
  • GitHubGraphqlError carries GitHub's error types.
  • The backfill task and the new task share startedTaskSyncContext.
  • design/github.md gets the rule: when GitHub fails the next-action read for a while, Junior syncs the pull request again after the rate limit resets.

via @BYK.

--

View Session [Sentry]

@sentry-junior
sentry-junior Bot added this pull request to stack #4307 November 25, 2026 13:58
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 25, 2026 11:40pm UTC

Request Review

@cursor cursor Bot 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 using default effort 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 3d02b60. Configure here.

sentry-junior Bot and others added 3 commits November 25, 2026 23:31
The webhook next-action sync failed in bursts when the installation ran
out of GraphQL rate limit (RATE_LIMIT with HTTP 200, a ZodError before
#4122). GitHub does not send a failed webhook again, so a
quiet pull request kept its stale action and Inbox item until its next
webhook.

A rate limit, a GraphQL error without a type, or a GitHub 5xx now starts
a task that syncs the pull request again. After a rate limit, the task
waits until the GraphQL limit resets. Other failures are logged as before.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot force-pushed the junior/pr-action-sync-retry branch from a070da0 to 776c8f5 Compare November 25, 2026 23:40
@BYK
BYK merged commit 7c9a155 into main Nov 25, 2026
53 checks passed
@BYK
BYK deleted the junior/pr-action-sync-retry branch November 25, 2026 23:56
BYK added a commit that referenced this pull request Nov 25, 2026
…er answers (#4317)

Stacked on #4316, on top of #4310, which
backfills the PRs that are in limbo now. This PR keeps new PRs out of
limbo, and it decides what counts as the requester's answer to a review
ask. It applies to webhooks and to the #4310 backfill. Every ask goes
only to the requester, through `requestPullRequestReviewers`, the call
#3250 makes on `ready_for_review`. The next read shows
the normal "Review requested" item.

## 1. Ready PRs that wait on nobody

New PRs can still enter limbo:

- The requester links GitHub after Junior opens the PR, so the request
at open and the request on `ready_for_review` had no login to ask.
- The request at open or on `ready_for_review` fails. Both only log a
warning.

`inLimbo` in `pull-request-action.ts` decides it. A PR is in limbo when
its derived action is none and all of these are true:

- It is open, not a draft, and auto-merge is off.
- No review ask for the requester is open: GitHub does not ask them, and
no comment-only review keeps an ask open (see 2).
- The requester has not commented, approved, or requested changes since
the last push.
- No reviewer approved it, so it does not wait only on others, and no
reviewer requests changes, so Junior does not act next.
- The requester did not remove their own review request since the last
ask (see 3).

A pending request for another person or a team does not take a PR out of
limbo. It asks nothing of the requester.

When a PR is in limbo and the base branch's required checks pass, the
sync asks for the requester's review. A webhook asks only a requester
who has not commented or reviewed, so a push never asks again. The
one-off backfill also asks one who acted before the last push
(`askAfterRequesterActed`). Review-again already reads the required
checks, so that reader is now shared as `readGitHubRequiredChecksPass`.
Until the checks pass, each `check_suite` webhook syncs again. An ask
counts only once Junior sends it, so a later check in the same sync can
still ask. Each limbo sync costs one more GraphQL read and one REST
branch-rules read until the requester is asked.

## 2. A comment-only review is not an answer

A comment-only review neither approves nor requests changes, but GitHub
drops the pending request on it. GitHub also records a reply in a review
thread as a comment-only review. Now the ask stays open
(`askStaysOpen`): the requester was asked, then left a comment-only
review, and has not approved, requested changes, or removed their own
request since. While the ask is open:

- The derivation treats the requester as asked, so the PR keeps its
"Review requested" item until they approve or request changes.
- The limbo check counts the ask as pending, so Junior sends no new
GitHub request.

A plain PR comment still means Junior acts next, as before. A change
request still follows the review-again flow.

## 3. A removed request stays removed

The requester can remove their own review request. GitHub records this
as a `review_request_removed` timeline event with the requester as both
actor and reviewer. After that, neither the backfill nor a webhook asks
them again, until someone asks them again on GitHub. If another person
removes the request, it does not count. The next-action read now
includes `ReviewRequestRemovedEvent` in its timeline.

## design/github.md

This PR adds the rule text that BYK confirmed:

- The change-request bullet now reads "When the requester comments,
approves, or requests changes, Junior acts next, and the Inbox stops
asking."
- "A comment-only review is not an answer to a review ask. The ask stays
open: the PR keeps asking the requester to review in the Inbox, and
Junior does not ask again on GitHub."
- "A ready Junior PR always has an Inbox ask or a pending GitHub review
request for its requester. When it asks nothing of the requester, Junior
asks for the requester's review on GitHub once the required checks pass.
A push does not ask a requester who has already reviewed or commented."
- "When the requester removes their own review request, Junior does not
ask them again until someone asks them again on GitHub."

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A6eedb91e2d3dfa1fd070e65575e7799d -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A6eedb91e2d3dfa1fd070e65575e7799d)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A6eedb91e2d3dfa1fd070e65575e7799d/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 776c8f5c Deployed Nov 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant