Skip to content

fix(github): enqueue merge-queue PRs when auto-merge is disabled - #42599

Open
SimonKaran13 wants to merge 1 commit into
pingdotgg:mainfrom
SimonKaran13:fix/enqueue-merge-queue-without-auto-merge
Open

SimonKaran13 wants to merge 1 commit into
pingdotgg:mainfrom
SimonKaran13:fix/enqueue-merge-queue-without-auto-merge

Conversation

@SimonKaran13

Copy link
Copy Markdown

Problem

On GitHub repositories where the target branch requires a Merge Queue and repository setting Allow auto-merge (allow_auto_merge) is disabled, merging a ready PR through T3 Code (either from the PR panel or via the pull_request_merge MCP tool) fails with:

GitHub returned an error: Auto merge is not allowed for this repository (at enablePullRequestAutoMerge)

Expected behavior: T3 adds the PR to the merge queue using GitHub's enqueuePullRequest mutation (matching GitHub's Merge when ready button on the web UI), without requiring repository auto-merge to be enabled.

Change

  • Added autoMergeAllowed to repository in query PullRequestActionState (packages/source-control-github/src/server/pullRequestReads.graphql).
  • Added mutation EnqueuePullRequest (packages/source-control-github/src/server/pullRequestMutations.graphql) returning mergeQueueEntry { pullRequest { ...PullRequestActionSummary } }, and regenerated GraphQL bindings (schema/github.graphql.ts, pullRequestReads.graphql.ts, pullRequestMutations.graphql.ts).
  • Updated GitHubPullRequestApi.runPullRequestAction so that when state.isMergeQueueEnabled === true and repository.autoMergeAllowed === false (for action === "merge", or enable-auto-merge on an already-ready PR), it invokes EnqueuePullRequest (preserving expectedHeadOid) instead of EnablePullRequestAutoMerge. Repositories with autoMergeAllowed: true keep existing EnablePullRequestAutoMerge behavior.
  • Added unit tests in packages/source-control-github/src/server/GitHubPullRequestApi.test.ts covering merge and ready enable-auto-merge on merge-queue branches with autoMergeAllowed: false (including expectedHeadOid forwarding, PullRequestActionSummary decoding, and empty-payload tolerance).

Scope

Fixes #36184 (reproduced at the service layer in 0c95b6cf2b and closed because the triage worker lacked a live organization repository with a required merge queue and auto-merge disabled).

Verification

  • Encountered live while merging PRs via T3 Code's pull_request_merge tool against a repository with a required Merge Queue on its target branch and Allow auto-merge disabled: pull_request_merge failed with Auto merge is not allowed for this repository (at enablePullRequestAutoMerge), while clicking Merge when ready on github.com enqueued the same PR immediately.
  • Regenerated GraphQL bindings with pnpm --filter @t3tools/source-control-github generate (schema/github.graphql.ts, pullRequestMutations.graphql.ts, pullRequestReads.graphql.ts).
  • Ran pnpm --filter @t3tools/source-control-github typecheck (effect-tsgo tsrs --noEmit) — exited 0 with no errors.
  • Ran vp lint on GitHubPullRequestApi.ts and GitHubPullRequestApi.test.ts — 0 warnings, 0 errors across 206 rules.
  • Ran vp fmt --check on the modified TypeScript files — passed.
  • Ran pnpm --filter @t3tools/source-control-github test — 23/23 test files, 455/455 tests passed, including both new enqueuePullRequest tests (verifying enqueuePullRequest receives { pullRequestId, expectedHeadOid }, enablePullRequestAutoMerge is not called, and the returned PullRequestActionSummary decodes).
  • Not verified end-to-end against a live GitHub Merge Queue from a rebuilt desktop binary (unit tests mock GitHub's GraphQL responses matching schema/github.graphql).

Written with Gemini 4 Neon in T3 Code (Antigravity harness).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T03:58:32.631619Z c3eb9b8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Nov 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3eb9b8fa4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

},
})
.pipe(
Effect.map((result) => result.enqueuePullRequest?.mergeQueueEntry?.pullRequest),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve a cancellable pending state for directly queued PRs

When this route enqueues a PR with autoMergeRequest: null (the response modeled in the added test), mapping only its pullRequest causes toPullRequestActionSummary to return autoMergeEnabled: false. The web primary-control resolver consequently shows Merge again, while web/mobile cancellation controls require that flag to be true. Refreshing cannot recover the pending state either: PullRequestCore never reads isInMergeQueue, and a repository-wide search finds dequeuePullRequest only in the schema, not an action handler. This leaves a successfully scheduled merge invisible and uncancellable from T3 while it waits in the queue. Carry queue membership through summary/detail and provide a dequeue path alongside this new enqueue route.

AGENTS.md reference: AGENTS.md:L63-L63

Useful? React with 👍 / 👎.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When repository auto-merge is disallowed, eligible merge-queue actions now enqueue the pull request. The action-state query reads the repository setting, and the enqueue mutation returns the queued pull request summary.

Changes: Merge queue enqueue

Layer / File(s) Summary
Enqueue GraphQL contract
packages/source-control-github/schema/github.graphql.ts, packages/source-control-github/src/server/pullRequestReads.graphql, packages/source-control-github/src/server/pullRequestReads.graphql.ts, packages/source-control-github/src/server/pullRequestMutations.graphql, packages/source-control-github/src/server/pullRequestMutations.graphql.ts
Adds the enqueue input and mutation, defines the nullable enqueue result, and includes repository autoMergeAllowed in the action-state query and result type.
Merge-queue action routing
packages/source-control-github/src/server/GitHubPullRequestApi.ts, packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
When auto-merge is disallowed, eligible merge-queue actions enqueue the pull request and include its expected head OID when available. Tests check the returned summary and the case where the enqueue response has no pull request.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to c3eb9

When repository auto-merge is disabled, merge-queue pull requests are now enqueued directly, as GitHub's web UI does. No concrete defect was established. The changed paths have mocked unit tests but were not exercised against a live merge queue.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: T3 Code now enqueues merge-queue PRs when repository auto-merge is disabled, which matches the code changes (autoMergeAllowed check, EnqueuePullRequest mutation, and r…
Description check Passed The description follows the template's sections (Problem, Change, Scope, Verification) and fills each with specific content. The Problem section gives the error, expected behavior, and environment. Th…
Linked Issues check Passed The only linked issue, #36184, is closed. It is historical context only, so its acceptance criteria are not active requirements for this pull request. No active directly linked coding requirements app…
Out of Scope Changes check Passed Every changed file relates to the merge-queue enqueue fix. pullRequestReads.graphql and its generated binding add repository.autoMergeAllowed. pullRequestMutations.graphql and its generated binding ad…
Full details: Title check

Explanation

The title names the main change: T3 Code now enqueues merge-queue PRs when repository auto-merge is disabled, which matches the code changes (autoMergeAllowed check, EnqueuePullRequest mutation, and routing in runPullRequestAction). It is specific and follows the conventional commit style used in the template.

Full details: Description check

Explanation

The description follows the template's sections (Problem, Change, Scope, Verification) and fills each with specific content. The Problem section gives the error, expected behavior, and environment. The Change section maps each edit to its file. Verification lists concrete commands and results and states what was not tested end-to-end. Scope links issue #36184 and explains its closure. Minor gaps: the template's leading comment asks for a conventional commit title, which is satisfied, and the agent attribution line is present. The Scope section cites a closed issue and a commit hash, which a maintainer may need to confirm, but the section is substantively complete.

Full details: Linked Issues check

Explanation

The only linked issue, #36184, is closed. It is historical context only, so its acceptance criteria are not active requirements for this pull request. No active directly linked coding requirements apply. The pull request still implements the behavior described in #36184: runPullRequestAction routes merge actions on merge-queue branches with autoMergeAllowed === false to EnqueuePullRequest instead of EnablePullRequestAutoMerge, and the action-state query now reads repository.autoMergeAllowed. The end-to-end behavior against a live merge queue was not verified, as the PR description states.

Full details: Out of Scope Changes check

Explanation

Every changed file relates to the merge-queue enqueue fix. pullRequestReads.graphql and its generated binding add repository.autoMergeAllowed. pullRequestMutations.graphql and its generated binding add EnqueuePullRequest and its types. schema/github.graphql.ts adds EnqueuePullRequestInput. GitHubPullRequestApi.ts selects the enqueue path. GitHubPullRequestApi.test.ts covers the new routing. These changes support that objective and are not unrelated. The change to enable-auto-merge on a PR that is not immediately mergeable still uses auto-merge, which keeps existing behavior. This assessment relies on the whole-PR summary; no focused diff inspection was performed.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4e6b1fa and c3eb9b8.

Files selected for processing: 7

  • packages/source-control-github/schema/github.graphql.ts
  • packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
  • packages/source-control-github/src/server/GitHubPullRequestApi.ts
  • packages/source-control-github/src/server/pullRequestMutations.graphql
  • packages/source-control-github/src/server/pullRequestMutations.graphql.ts
  • packages/source-control-github/src/server/pullRequestReads.graphql
  • packages/source-control-github/src/server/pullRequestReads.graphql.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PR Merge fails when a merge queue is required and auto-merge is disabled

1 participant