Skip to content

[AUT-4128] mergequeue: dequeue PRs when trigger condition is no longer met - #44

Merged
FranciscoKurpiel merged 1 commit into
mainfrom
fix-dequeue-on-missed-trigger-events
Nov 9, 2026
Merged

FranciscoKurpiel merged 1 commit into
mainfrom
fix-dequeue-on-missed-trigger-events

Conversation

@FranciscoKurpiel

@FranciscoKurpiel FranciscoKurpiel commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

GitHub webhook events that remove a pull request from the merge queue (auto_merge_disabled, unlabeled, closed) can occasionally fail to be emitted or delivered by GitHub. Previously, ReadyForMerge only queried reviewDecision and statusCheckRollup, so a pull request whose auto_merge_disabled or unlabeled webhook was missed stayed in the queue (and was moved back from the suspend queue into the active queue on every push to the base branch).

Changes

  • internal/githubclt: Extend ReadyForMergeStatus and reviewAndCIStatus to query closed, autoMergeRequest { enabledAt }, and labels(first: 100) in the existing GraphQL query.
  • internal/mergequeue:
    • Pass the configured enqueue trigger (TriggerOnAutomerge, TriggerLabels) and an empty-queue callback when creating a queue.
    • Check q.dequeueRequired(status) at the start of evalPRAction (before approval checks, branch updates, head label updates, or CI triggers) and in resumeIfPRMergeStatusPositive (before resuming a suspended PR).
    • Dequeue closed PRs without resetting commit status to pending, and dequeue PRs that no longer satisfy the enqueue trigger while resetting commit status to pending.
    • Remove queues that become empty after self-dequeuing their last PR via the coordinator event loop.
    • Guard q.suspended lookup in resumeIfPRMergeStatusPositive with q.lock.

AUT-4128

GitHub webhook events that remove a pull request from the merge queue (auto_merge_disabled, unlabeled, closed) can be missed. Previously,ReadyForMerge only queried review and CI status, so a pull request whose auto_merge_disabled or unlabeled event was dropped remained in the queue and was repeatedly moved back to the active queue on base-branch pushes.

Extend ReadyForMergeStatus to include Closed, AutoMergeEnabled, and Labels from the existing GraphQL query, and verify queue eligibility in both evalPRAction and resumeIfPRMergeStatusPositive before updating branches, adding the head label, triggering CI, or resuming suspended PRs.
@FranciscoKurpiel
FranciscoKurpiel marked this pull request as ready for review November 9, 2026 10:59
@FranciscoKurpiel
FranciscoKurpiel merged commit 8b51639 into main Nov 9, 2026
3 checks passed
@FranciscoKurpiel FranciscoKurpiel changed the title mergequeue: dequeue PRs when trigger condition is no longer met [AUT-4128] mergequeue: dequeue PRs when trigger condition is no longer met Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant