Repository navigation
fix(source-control-github): merge stacked pull requests through the async merge API - #198
Conversation
…sync merge API Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
PR SummaryMedium Risk Overview The provider parses the async response, polls by UUID (up to ten times, one second apart) until the job is no longer pending, and surfaces failures, unreadable bodies, or a merge still running on GitHub. Tests mock the GraphQL refusal and cover a successful async merge plus immediate failure, polled failure, poll exhaustion, and bad poll payloads. Reviewed by Cursor Bugbot for commit 2749fb0. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 47 minutes. View limit details
|
| Layer / File(s) | Summary |
|---|---|
Route and verify asynchronous merges packages/source-control-github/src/server/GitHubPullRequestApi.ts, packages/source-control-github/src/server/GitHubPullRequestApi.test.ts |
The API detects GraphQL refusals that name the asynchronous merge REST route and sends the selected merge settings and expected head SHA. It treats HTTP 409 as success and polls responses with a UUID. Tests verify the REST request and that a failed poll surfaces GitHub’s failure message. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant GitHubPullRequestApi
participant GitHubGraphQL
participant GitHubAsyncMergeREST
GitHubPullRequestApi->>GitHubGraphQL: Submit mergePullRequest mutation
GitHubGraphQL-->>GitHubPullRequestApi: Return asynchronous-merge refusal
GitHubPullRequestApi->>GitHubAsyncMergeREST: PUT merge settings and expected head SHA
GitHubAsyncMergeREST-->>GitHubPullRequestApi: Return accepted response with UUID
GitHubPullRequestApi->>GitHubAsyncMergeREST: Poll merge status by UUID
GitHubAsyncMergeREST-->>GitHubPullRequestApi: Return merge status
Suggested labels: size:L
Suggested reviewers: juliusmarminge
Merge Risk: 
Moderate · previous review 32215
-
Stacked merges can report success while unfinished, failed, or pending with different settings. Correct these response-handling paths before merging.
Pre-merge checks: 
3 · 
1
-
Failed checks: 1 inconclusive Passed checks: 3 passedFull details: Description check
-
Explanation
The description supplies a clear Problem, Change, Scope and approval, and Verification section, which covers the template's required parts. The Problem section states the stacked-PR merge failure and its cause. The Change section explains the async REST fallback, the UUID polling, the result handling, and the auto-merge exclusion. The Scope section argues the change is a small fix of an obvious bug in one provider, with no new setting or client change. The Verification section reports that check:changed passes, names the two new test cases, and states the change was not run against a real stacked pull request. Gaps: the Scope section does not link a triaged issue or maintainer approval, and it does not explain why the fix qualifies without one beyond calling it small and obvious. The template also asks for an agent/model line only if an agent was used, so its absence is not a gap. Because the Scope section is thin on the approval rationale the template asks for, the description is mostly complete but not fully complete.
Resolution
Add a link to the triaged bug issue or the discussion with explicit maintainer approval, including the approval comment. If no prior issue exists, expand the Scope and approval section to explain why this is a very small, focused fix of an obvious bug that qualifies without prior approval. Keep the existing Problem, Change, and Verification content as written.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
…r are already pending Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Problem
Merging a pull request that is part of a stack failed with "This pull request is part of a stack and must be merged using the asynchronous merge REST API", because the GitHub provider only used the GraphQL
mergePullRequestmutation.Change
When GitHub refuses a
mergeaction with that message, the provider retries throughPUT /pulls/{n}/merge-asyncwith the same head SHA, method, bypass, and commit message. It then follows the returned UUID for up to ten polls. Only a merged or enqueued result is success: a failed, still-pending, unreadable, or already-pending (409) result is reported as an error.enable-auto-mergekeeps GitHub's own refusal, since the async route has no auto-merge. Like the old route, it merges every open pull request below the one clicked.Scope and approval
Small fix of an obvious bug in one provider; no new setting or client change.
Verification
vp run check:changedpasses.GitHubPullRequestApi.test.tshas two new cases, a stacked merge that goes through the async route and one that GitHub then fails in the background. Not run against a real stacked pull request.