Fix PR auto-update to catch behind PRs with pending checks#142
Conversation
The workflow only updated PRs whose mergeStateStatus was exactly BEHIND. GitHub reports BEHIND only when a PR is behind AND otherwise mergeable; a behind PR with pending CI or unsatisfied reviews reports as UNSTABLE/BLOCKED, masking the behind-ness. With ~20-min CI plus bot reviewers, behind PRs are almost always non-clean right after a merge lands, so the workflow skipped exactly the PRs a human then updates by hand. Now compute behind-ness directly from the compare API (behind_by > 0) and update any behind, non-draft, conflict-free PR regardless of its check/review state. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. 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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe branch-update workflow now lists eligible pull requests, checks each branch against ChangesPR branch update workflow
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Sequence Diagram(s)sequenceDiagram
participant Workflow as update-pr-branches.yml
participant PRList as gh pr list
participant CompareAPI as GitHub Compare API
participant BranchUpdater as PR branch updater
Workflow->>PRList: List open non-draft PRs
PRList-->>Workflow: Return number and headRefName
Workflow->>CompareAPI: Compare main...head
CompareAPI-->>Workflow: Return behind_by
alt behind_by greater than 0
Workflow->>BranchUpdater: Update PR branch
else up to date
Workflow-->>Workflow: Record up-to-date skip
end
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed0a558bf2
ℹ️ 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".
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/update-pr-branches.yml:
- Around line 38-40: Update the PR discovery loop around gh pr list to capture
its output and status before iterating, rather than executing it directly in
command substitution. If gh pr list fails, exit the workflow step with a
non-zero status; otherwise preserve the existing filtering and row iteration
behavior.
- Around line 39-42: Update the PR metadata query and row parsing in the
workflow loop to also retrieve each PR’s headRepositoryOwner, then construct the
compare API reference as main...<owner>:<head> instead of using headRefName
alone. Preserve the existing behind_by lookup and draft-PR filtering while
ensuring fork PR heads retain their repository ownership.
🪄 Autofix (Beta)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 73214fe2-5564-4f2a-94cb-327d718a2ffa
📒 Files selected for processing (1)
.github/workflows/update-pr-branches.yml
- Fail the job when PR discovery fails: capture `gh pr list` output/exit status before iterating instead of swallowing a failure inside `$(...)`, so an API/auth outage aborts the job loudly instead of reporting "no PRs to update". - Qualify fork PR heads in the compare request: fetch headRepositoryOwner and compare against `<owner>:<branch>` when the head repo differs from the base repo, so a future fork PR compares its own commits instead of an unrelated same-named branch (or a 404) in the base repo. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
update-pr-branches.yml (merged in #142) pushes merge-from-main commits as github-actions[bot]. claude-code-action hard-fails for non-human actors ("Workflow initiated by non-human actor"), so every auto-updated PR got a red claude-review check the moment the auto-updater did its job — first seen on PR #143 within a minute of #142 landing. Skip the job for bot-triggered synchronize events instead of allowlisting the bot: a merge from main leaves the PR diff unchanged, so re-reviewing it would burn a full review run on nothing new. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mf3c4CzpfCCqAQA2k4UQKH
Problem
update-pr-branches.ymlis supposed to keep every open PR up to date with main so no one clicks "Update branch" by hand. But it only acted on PRs whosemergeStateStatus == BEHIND.GitHub reports
BEHINDonly when a PR is behind main and otherwise mergeable (checks green, reviews satisfied, no conflicts). A behind PR with pending CI or unsatisfied reviews reports asUNSTABLE/BLOCKED, which masks the behind-ness. With ~20-minute CI plus bot reviewers, behind PRs are almost always non-clean right after a merge lands — so the workflow skipped exactly the PRs that a human then updates manually once checks settle.Fix
Compute behind-ness directly from the compare API (
behind_by > 0) instead of trusting the composite status. Now any behind, non-draft, conflict-free PR is auto-updated regardless of its check/review state. Conflicted PRs still fail cleanly and are listed as "needs human" in the job summary.Notes
Summary by CodeRabbit