Repository navigation
fix(github): Do not stack pull requests from the trunk or on looping base branches - #3153
Merged
Merged
Conversation
…base branches A weekly sync PR (master -> java-v9) was opened while a long-lived collection PR (java-v9 -> master) was open. The stack walk followed java-v9 -> master -> java-v9 until the depth limit and created a stack that repeated both PRs. Merging the sync PR then retargeted the collection PR onto its own head, so GitHub marked it merged. Skip stacking when the head is the default branch, stop the walk at the default branch, and give up when the walk reaches a PR it already saw. Co-Authored-By: Alexander Dinauer <alexander.dinauer@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
There was a problem hiding this comment.
The fix is right for the sentry-docs case. The head.ref === trunk guard stops the weekly sync PR from stacking, and the chain.includes guard catches other loops. I ran tests/github-plugin.test.ts locally and all 120 tests pass. When I removed each guard, its own case failed.
One gap before this lands:
- No test covers the
branch !== trunkstop in the walk. When I removed it, all 120 tests still passed. This guard matters while a sync PR is open. Take B (feat/b→feat/a), A (feat/a→main), and an open sync PR S (main→java-v9). Without the guard, the walk looks uphead=main, finds S, and calls stack create with[S, A, B]whenjava-v9has no open PR. When the collection PR is open, the loop guard returns early and the valid stack is silently skipped. Please add a case where thehead=mainlookup returns an open PR, and assert that stack create gets[A, B].
Also, the comment No parent: \branch` is the trunk.` is now wrong. The loop no longer queries the trunk, so no parent means the base branch has no open PR.
I agree that the long-lived integration branch question (feat/x → java-v9 stacking on the collection PR) belongs in a follow-up.
… open The stacking test returned no open pull request for the trunk, so it passed with or without the stop at the trunk. Give the trunk an open sync pull request so the test fails if the walk adds it to the stack. Co-Authored-By: Thomas Jiang <20501235+thomasjiangcy@users.noreply.github.com>
thomasjiangcy
approved these changes
Nov 11, 2026
23 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In getsentry/sentry-docs, a scheduled automation opened the weekly sync PR getsentry/sentry-docs#20685 (
master→java-v9) while the long-lived collection PR getsentry/sentry-docs#19963 (java-v9→master) was open.github_createPullRequesttreated #19963 as the PR below the sync PR. The stack walk then wentjava-v9→master→java-v9, found the sync PR again at each step, and ran untilMAX_STACK_DEPTH. It created stack 20686, which lists both PRs again and again. When the sync PR merged, GitHub retargeted #19963 ontojava-v9, its own head, and marked it merged.masterdid not change, but the collection PR had to be opened again (getsentry/sentry-docs#20718).Changes in
stackGitHubPullRequest:The GitHub plugin docs now list these cases.
Open question: a PR into a long-lived integration branch, such as
feat/x→java-v9, still stacks on the collection PR (java-v9→master). If someone merges that stack as one group, the collection branch could land on the trunk early. A fix probably needs a rule for when the PR below is a long-lived branch, for example a draft PR, so this PR does not change it.via alexander.dinauer.
--
View Session [Sentry]