fix: auto-queue re-enables auto-merge on ejected PRs - #276
Conversation
When the merge queue ejects a PR (timeout, failed checks, conflicts), GitHub disables auto-merge. No PR event fires, so the event-driven auto-queue never re-enables it. Add a scheduled job that scans for open PRs with all required labels, no blocking labels, not draft, and no auto-merge enabled, then re-enables auto-merge on each. Assisted-by: Claude Code <noreply@anthropic.com> Signed-off-by: omer-vishlitzky <omer.vishlitzky@gmail.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: omer-vishlitzky The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Warning Review limit reached
Next review available in: 59 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository: osac-project/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThe auto-queue workflow now runs every ten minutes. A scheduled job finds eligible open pull requests and enables rebase auto-merge. Pull-request-triggered runs continue to use the existing auto-merge job. ChangesAuto-queue requeue flow
Sequence Diagram(s)sequenceDiagram
participant GitHubActionsScheduler
participant AutoQueueWorkflow
participant GitHubCLI
participant OpenPullRequests
GitHubActionsScheduler->>AutoQueueWorkflow: Start scheduled run
AutoQueueWorkflow->>GitHubCLI: List open pull requests
GitHubCLI->>OpenPullRequests: Read draft, auto-merge, and label state
OpenPullRequests-->>AutoQueueWorkflow: Return pull request data
AutoQueueWorkflow->>GitHubCLI: Enable rebase auto-merge for eligible pull requests
Possibly related PRs
🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
|
🤖 Finished Review · ✅ Success · Started 10:11 PM UTC · Completed 10:25 PM UTC Commit: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/auto-queue.yml:
- Around line 75-81: Update the gh pr list invocation in the auto-merge
candidate query to request all relevant open pull requests by setting an
explicit sufficiently high --limit or enabling pagination. Preserve the existing
jq eligibility filtering and number output while ensuring candidates beyond the
default 30-result page are processed.
- Around line 82-85: Update the auto-merge requeue loop to track whether any gh
pr merge invocation fails, continue processing remaining pull requests, and exit
non-zero after the loop when failures occurred instead of masking them with
echo. Also configure gh pr list to paginate through all pull requests rather
than limiting results to the default 30.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4d0d4377-f731-41d7-be72-617a4d0b848d
📒 Files selected for processing (1)
.github/workflows/auto-queue.yml
| ' | while read -r pr; do | ||
| echo "Re-enabling auto-merge on PR #$pr" | ||
| gh pr merge "$pr" --repo "${{ github.repository }}" --auto --rebase || echo "Failed to enable auto-merge on PR #$pr" | ||
| done |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
file=".github/workflows/auto-queue.yml"
wc -l "$file"
cat -n "$file"
printf '\n--- workflow diff stat ---\n'
git diff --stat -- "$file"
printf '\n--- relevant commands ---\n'
rg -n -C 4 'gh pr list|gh pr merge|while read|permissions:|set -e|pull_request|schedule' "$file"Repository: osac-project/osac
Length of output: 7204
🌐 Web query:
GitHub CLI gh pr list default limit pagination documentation
💡 Result:
The GitHub CLI command gh pr list has a default limit of 30 items [1][2]. To change the number of items fetched, you can use the --limit (or -L) flag followed by the desired number [1][3]. For example, running gh pr list --limit 100 will fetch up to 100 pull requests. Regarding pagination and totals: - The gh pr list command treats the --limit flag as a cap for the current command call [3][4]. - It does not natively expose aggregate total counts (such as totalCount) when using --json output [3][4]. - If you require a true total count of pull requests, the recommended approach is to use the gh api command to query the GitHub GraphQL API directly [3][4]. - For advanced pagination scenarios or fetching more than a single set of results, you can use gh api with the --paginate flag, often combined with --jq to process the output [3][4].
Citations:
- 1: https://cli.github.com/manual/gh_pr_list
- 2: https://manpages.ubuntu.com/manpages/noble/man1/gh-pr-list.1.html
- 3: https://github.com/github/gh-cli/blob/v2.94.0/skills/gh/SKILL.md
- 4: https://github.com/cli/cli/blob/c14cbaa2/skills/gh/SKILL.md
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- merge failure is masked ---'
(
set -o pipefail
gh() {
if [[ "$1 $2" == "pr list" ]]; then
printf '123\n'
else
return 9
fi
}
gh pr list | while read -r pr; do
gh pr merge "$pr" --auto --rebase || echo "Failed to enable auto-merge on PR #$pr"
done
printf 'pipeline_status=%s\n' "$?"
)
printf '%s\n' '--- listing failure remains detectable only when the loop does not mask it ---'
(
set -o pipefail
gh() {
if [[ "$1 $2" == "pr list" ]]; then
return 7
fi
}
set +e
gh pr list | while read -r pr; do
:
done
printf 'listing_pipeline_status=%s\n' "$?"
)Repository: osac-project/osac
Length of output: 349
Propagate requeue failures.
When gh pr merge fails, || echo ... makes the loop return success. The scheduled job can report success while auto-merge remains disabled. Accumulate failures and exit non-zero after processing all pull requests. Also paginate gh pr list, which otherwise returns only 30 pull requests.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/auto-queue.yml around lines 82 - 85, Update the auto-merge
requeue loop to track whether any gh pr merge invocation fails, continue
processing remaining pull requests, and exit non-zero after the loop when
failures occurred instead of masking them with echo. Also configure gh pr list
to paginate through all pull requests rather than limiting results to the
default 30.
Source: MCP tools
ReviewFindingsHigh
Medium
Low
Labels: PR modifies GitHub Actions workflow file (.github/workflows/auto-queue.yml) Next steps:
|
There was a problem hiding this comment.
See the review comment for full details.
Note: The following inline comments could not be posted on the diff (GitHub returned 422) and are included here instead:
.github/workflows/auto-queue.yml:75: [medium] edge-case
gh pr list defaults to returning only 30 results. If the repository has more than 30 open PRs, eligible PRs beyond the first page will be silently skipped and never have auto-merge re-enabled.
Suggested fix: Add --limit 200 (or a suitably large number) to the gh pr list command.
.github/workflows/auto-queue.yml(file-level): Line 1 · [medium] permission-expansion
The workflow has no top-level permissions: block. Without explicit permission scoping, the workflow inherits the repository's default token permissions. Nearly every other workflow in this repository explicitly sets permissions. Adding a restrictive permissions block follows least-privilege and matches the repository convention.
Suggested fix: Add a top-level permissions: {} block to restrict the default GITHUB_TOKEN.
.github/workflows/auto-queue.yml:66: [low] logic-error
The requeue-eligible-prs job does not check whether the PR author is a repository collaborator before re-enabling auto-merge. The event-driven enable-auto-merge job gates on collaborator status, but the scheduled job bypasses this. The practical risk is low since the required labels are Prow-managed via OWNERS files.
.github/workflows/auto-queue.yml:75: [low] error-handling
The gh pr list ... | while read -r pr pipeline means failures from gh pr list are swallowed. The step exits 0 with no indication the scan never ran.
Suggested fix: Use set -euo pipefail or capture the output into a variable first.
.github/workflows/auto-queue.yml:72: [low] permission-expansion
The scheduled job expands the operational scope of MERGE_QUEUE_TOKEN from acting on a single event-triggered PR to iterating over all open PRs. This is acceptable for the use case but broadens the token's blast radius.
.github/workflows/auto-queue.yml:9: [low] quoting-convention
Cron expression uses double quotes, while unit-tests.yml uses single quotes for its cron expression. Minor style inconsistency.
Suggested fix: Change to single quotes for consistency: cron: '*/10 * * * *'
Addresses review feedback: gh pr list defaults to 30 results, silently skipping eligible PRs. Also add set -euo pipefail and capture output into a variable so API failures are not swallowed. Assisted-by: Claude Code <noreply@anthropic.com> Signed-off-by: omer-vishlitzky <omer.vishlitzky@gmail.com>
Assisted-by: Claude Code <noreply@anthropic.com> Signed-off-by: omer-vishlitzky <omer.vishlitzky@gmail.com>
|
🤖 Finished Review · ✅ Success · Started 11:20 PM UTC · Completed 11:34 PM UTC Commit: |
|
Review skipped — this PR is already merged. The Posted by fullsend pre-review check |
|
Review skipped — this PR is already merged. The Posted by fullsend post-review check |
Summary
When the merge queue ejects a PR (timeout, failed checks, conflicts), GitHub disables auto-merge. No PR event fires, so the event-driven auto-queue never re-enables it — ejected PRs sit dead.
Adds a scheduled job (every 10 min) that scans for open PRs with:
Re-enables auto-merge with
--rebaseon each match.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit