Skip to content

fix(github): Repair repository names left stale by the lifecycle backfill - #4192

Merged
BYK merged 1 commit into
mainfrom
byk/github-repo-name-repair
Nov 24, 2026
Merged

BYK merged 1 commit into
mainfrom
byk/github-repo-name-repair

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

This repairs repository names that #4147's backfill left stale.

GitHub migration 0020 from that PR added missing repositories to Junior's code index with ON CONFLICT DO NOTHING. When the index already had a repository under its name from before a rename, it kept that name, and 0021 then dropped the newer copy in the plugin table. The plugin finds pull requests by repository name for merge conflict checks, next-action sync, preview images, and Resume. For a renamed repository, those lookups miss until a lifecycle webhook records the new name.

Repair. The GitHub plugin reads the current full_name of each repository in the code index from GitHub by its id, and records each name that changed. The requests use one metadata-only installation token and run four at a time. A 404 leaves the stored name as it is. Any other error is logged for that repository, and the repair moves on to the next.

Runs once. The heartbeat starts the repairRepositoryNames task with a fixed key until a done mark is in plugin state. The task checks the mark, repairs the names, and sets the mark. This uses the started tasks from #4109, so the GitHub reads run outside the heartbeat, a failed run retries, and two heartbeats cannot start two repairs. After the mark is set, each heartbeat does one state read for it.

Plugin API. PluginCodeChanges.recordRepository({ name, providerId, updatedAt }) is a new write. It is the repository upsert that record() already runs, now a function of its own, so the same updatedAt guard applies and an older name cannot replace a newer one. The repair writes with the time of the run. To list the stored repositories, the repair reads all of the plugin's code changes with codeChanges.list({}), so it needs no new read. That is one query, run once.

via @BYK.

--

View Session [Sentry]

@sentry-junior
sentry-junior Bot requested a review from BYK November 24, 2026 12:55
@vercel

vercel Bot commented Nov 24, 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 24, 2026 12:55pm UTC

Request Review

@BYK
BYK enabled auto-merge (squash) November 24, 2026 12:56
@BYK
BYK merged commit 504d0cd into main Nov 24, 2026
59 checks passed
@BYK
BYK deleted the byk/github-repo-name-repair branch November 24, 2026 13:05
BYK added a commit that referenced this pull request Nov 25, 2026
… in limbo (#4310)

The next action of a Junior pull request ("Review requested", "Ready to
merge", or the held-draft ask from #4306) is derived
only when a webhook that can change it arrives. Two groups of open PRs
have no item:

- Quiet PRs that went silent before a rule shipped. Example:
#2382, where GitHub asked for the requester's review on
11-12, before #3395, and no webhook has come since.
About 14 of BYK's PRs are `clean` and not approved. With
#4304 they derive `merge`, but no webhook will come to
derive it.
- **PRs in limbo:** ready PRs that ask nothing of their requester,
because no one ever asked for the requester's review. They were opened
ready, or became ready, before #3250, or the requester
linked GitHub later.

**This is a one-off run with a done key, not a recurring poll.** A new
started task, `backfillPullRequestActions`, does the run. It follows the
`repository-name-repair` one-off (#4192):

- After deploy, the GitHub heartbeat starts one page per tick: 50 open
Junior PRs, in GitHub id order. Each page has its own task key.
- Each page goes through the webhook sync path,
`syncGitHubPullRequestActions`, with the same claim and the same
concurrency limit of 5. A PR that no person asked for returns before any
GitHub read.
- After the last page, the task sets
`pull-request-action-backfill:v1:done` in plugin state, and the
heartbeat never starts it again. To run it again after a later rule
ships, bump `VERSION` in `pull-request-action-backfill.ts`.

## Limbo

`inLimbo` in `pull-request-action.ts` uses only what `nextAction`
already reads, plus the head commit time. An open Junior PR is in limbo
when all of these are true:

- The derived action is none.
- It is not a draft, and auto-merge is off.
- It has a stored requester with a linked GitHub login.
- GitHub has no pending user review request for the requester. A pending
request for another person or a team does not count, because it asks the
requester for nothing.
- The requester has not reviewed or commented since the last push (the
head commit's `committedDate`).
- No reviewer approved it. Such a PR waits only on others.
- No reviewer, the requester included, requests changes. On such a PR,
Junior acts next.

For each PR in limbo, the backfill asks for the requester's review on
GitHub. It uses `requestPullRequestReviewers`, the same call that
#3250 makes on `ready_for_review`. It asks only the
requester, and never code owners or teams. The next read then derives
the normal "Review requested" item. To show approval on a PR that is not
`clean`, the merge-state read now computes `reviewOutcome` for every
open PR. `nextAction` still reads it only for `clean` PRs.

**Side effect:** after deploy, the backfill sends one GitHub review
request to the requester on each PR in limbo, for all users. GitHub data
from 11-25: 98 open, ready Junior PRs, from 21 requesters, have an
assignee that GitHub does not ask for a review, are not approved, have
no change request, and have auto-merge off. This is an upper bound. PRs
that derive `merge`, PRs where the requester commented after the last
push, and PRs with no stored requester or linked login are not asked.
BYK has 34 of these PRs. About 14 of them derive "Ready to merge" under
#4304, so BYK gets about 20 review requests.

Dismissed items stay dismissed. The sync changes an item only when the
derived action is different from the saved one.
getsentry/sentry-rust#1400 has `merge` saved, so its dismissed "Ready to
merge" item does not come back. A PR in limbo has no saved action, so
asking for its review cannot bring back a dismissed item.

Started plugin tasks now get `inboxItems` and `users.readIdentity`, as
plugin routes do. The task needs them to show items and to map the
requester's linked GitHub login.

PRs that go into limbo after this one-off are handled by the PR stacked
on this one.

## Proposed design/github.md rule (not edited here)

> 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,
but not after a push when the requester has already reviewed or
commented.

<!-- 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 — 959fee3b Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant