gh-stack
gh-stack copied to clipboard
merge: merge-queue detection fails when ref.rules{type} errors, falls back to direct_merge
gh stack merge falls back to a direct merge on a repository that requires a merge queue, so the merge is rejected:
$ gh stack merge 1890 --yes
Merging #1888, #1889, #1890 into main via squash...
✗ merge failed: Repository rule violations found
Changes must be made through the merge queue
gh-stack v0.2.1, gh 2.102.0.
Cause
The merge-queue detection sends one GraphQL query for mergeQueue(branch) and ref.rules(first:50){nodes{type}}. On our repository the rules part fails with a server error every time, while mergeQueue on its own works:
mergeQueue(branch:"main"){id}returns the queue id.ref(qualifiedName:"refs/heads/main"){rules(first:50){nodes{type}}}returns "Something went wrong while executing your query" (request ids82AC:1DBA9D:59A046C,8286:1D1C60:596BFF2,829E:81BF7:5D1E100:85D7C9A:6AD68A44).totalCountworks, so resolvingtypeis what fails. The ruleset includes newer rule types such ascode_qualityandcopilot_code_review.
Because both fields are in one query, the error discards the valid mergeQueue answer. The detection then returns false, and the merge is sent with merge_action: "direct_merge".
Workaround
Enqueueing the top PR directly works and queues the whole stack:
gh api -X PUT repos/OWNER/REPO/pulls/N/merge-async -f merge_action=merge_queue
Suggested fix
- Query
mergeQueueseparately fromref.rules, or treat a non-nullmergeQueueas enough whenruleserrors. - Do not fall back to a direct merge when detection fails; report the error instead, or offer a
--queueflag to force the queue.