Repository navigation
Fix merge queue state and event handling issues - #41
Merged
Merged
Conversation
…SinceIfNewerByBranch
FranciscoKurpiel
marked this pull request as ready for review
October 27, 2026 19:23
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.
This PR addresses several issues identified in
directoriusproduction logs:processPRevaluates a PR that is already closed or merged (for example, when apushevent on the base branch arrives before or without thepull_requestclosedwebhook), it previously suspended the PR instead of removing it from the queue. This overwrote the merged commit'sdirectoriusstatus back topendingand caused the closed PR to be moved back into the active queue on subsequent pushes to the base branch.processCheckRunEvent: InprocessCheckRunEvent,SetPRStaleSinceIfNeweris only called inside theif err != nilbranch whenNewBaseBranchfails (passing anilbase branch and dereferencing it), and is skipped whenNewBaseBranchsucceeds. Also avoid mutating the outerloggeracross loop iterations.check_run/statuslogs toDebugand fixSetPRStaleSinceIfNewerByBranch: Non-PRcheck_runandstatusevents (such as pushes tomaster, scheduled workflows, or already-closed PRs) have an emptypull_requests/brancheslist and were logged atInfolevel, flooding production logs. Also fixSetPRStaleSinceIfNewerByBranchoverwritingmissingwhen a repository has queues for multiple base branches.Coordinator.sync: During initial synchronization,logger = logger.With(pr.LogFields...)is reassigned in a loop over all open PRs, causing every subsequent log line insyncto accumulate duplicategithub.pull_requestandgit.branchfields for all processed PRs.AddLabelcalls and misleading success logs:prAddQueueHeadLabelis called on every periodicprocessPRrun even when the head PR already has the label, and bothprAddQueueHeadLabelandprRemoveQueueHeadLabellog that the label was added/removed even when the GitHub API call failed.sync: On startup,syncremoves themergequeue-firstlabel from the previously active head PR and re-enqueues all PRs sorted only byEnqueuedAt, losing the head position of the PR whose CI was already running before the restart.processPRevaluation atDebuginstead ofError: When an in-flightprocessPRrun is intentionally canceled (e.g., viacancelActionForPRwhen the PR is dequeued after merging),evalPRActionreturnscontext.Canceled. Checkingerrors.Is(err, context.Canceled)beforelogger.Erroravoids emitting a false-positive error and stacktrace.