Skip to content

t3005: Fix review-bot-gate to handle rate-limited bots via status check fallback#3006

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/t3005-review-bot-gate-rate-limit
Mar 6, 2026
Merged

t3005: Fix review-bot-gate to handle rate-limited bots via status check fallback#3006
marcusquinn merged 1 commit intomainfrom
bugfix/t3005-review-bot-gate-rate-limit

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Mar 6, 2026

Summary

  • When all review bots are rate-limited (posting quota notices instead of real reviews), the gate now falls back to checking formal GitHub commit status checks
  • If any known bot (e.g., CodeRabbit) posted a SUCCESS status check on the PR's head commit, the gate passes — the bot completed its analysis even though its comment was a rate-limit notice
  • Both the workflow (.github/workflows/review-bot-gate.yml) and the helper script (.agents/scripts/review-bot-gate-helper.sh) are updated with the any_bot_has_success_status() fallback function

How it works

The new any_bot_has_success_status() function:

  1. Gets the PR's head SHA via gh pr view
  2. Queries repos/{owner}/{repo}/commits/{sha}/statuses for success statuses
  3. Falls back to repos/{owner}/{repo}/commits/{sha}/check-runs for success check runs
  4. Matches status context names against known bot patterns (case-insensitive)

Gate logic order (updated)

  1. Real review found → PASS
  2. Rate-limited + SUCCESS status check → PASS (new, GH#3005)
  3. PR too young → PASS (pending)
  4. No reviews, no status checks → WAITING/FAIL

Evidence

Closes #3005

Summary by CodeRabbit

Release Notes

  • New Features

    • Added fallback mechanism for review gate: when rate-limited bots have successful status checks, PRs are now approved using status check results as fallback verification.
    • Enhanced messaging to indicate when status-check fallback is applied in the gating process.
  • Chores

    • Updated automation to evaluate bot status checks as part of the review gate decision logic.

…e rate-limited

When all review bots post rate-limit notices instead of real reviews, the
gate now checks if any bot posted a formal GitHub commit status check with
SUCCESS state (e.g., CodeRabbit's status context). If so, the PR is treated
as reviewed — the bot completed its analysis even though the comment was a
rate-limit notice.

Both the workflow (.github/workflows/review-bot-gate.yml) and the helper
script (.agents/scripts/review-bot-gate-helper.sh) are updated with the
any_bot_has_success_status() fallback function.

Closes #3005
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Added a new any_bot_has_success_status() function to query GitHub commit status checks and detect SUCCESS conclusions from known review bots. Integrated this function as a fallback in the review-bot-gate workflow: when rate-limited bots are detected, the workflow now checks for successful status checks instead of failing. If found, the PR is treated as reviewed with a status-check fallback indicator.

Changes

Cohort / File(s) Summary
Status-Check Fallback Function
.agents/scripts/review-bot-gate-helper.sh
Added any_bot_has_success_status(pr_number, repo) function to query GitHub commit statuses and check-runs for SUCCESS conclusions from known bot contexts. Function returns 0 on success with logging, 1 otherwise.
Workflow Integration & Messaging
.github/workflows/review-bot-gate.yml
Integrated any_bot_has_success_status() into gate decision logic as a fallback when rate-limited bots are detected. Added status_fallback output flag across check, summary, and gate result steps. Updated user-facing messaging to reflect status-check fallback options and gating behavior.

Sequence Diagram

sequenceDiagram
    participant WF as Workflow
    participant Helper as Helper Script
    participant GH as GitHub API
    
    WF->>WF: Detect rate-limited bots in comments
    alt Rate-Limited Bots Found
        WF->>Helper: Call any_bot_has_success_status()
        Helper->>GH: Query commit statuses (head SHA)
        Helper->>GH: Query check-runs for known bots
        alt SUCCESS Status Found
            GH-->>Helper: Return SUCCESS conclusion
            Helper-->>WF: Return 0 (success)
            WF->>WF: Set status_fallback=true
            WF->>WF: Treat PR as PASS (with fallback)
        else No SUCCESS Status
            GH-->>Helper: Return failure/pending
            Helper-->>WF: Return 1 (failure)
            WF->>WF: Fail gate with rate-limit error
        end
    else No Rate-Limited Bots
        WF->>WF: Continue normal gate logic
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #2982 — Introduced rate-limit detection logic that this PR augments with a commit-status fallback mechanism
  • PR #2739 — Modified review-bot-gate-helper.sh with bot-comment checking logic; this PR extends the same helper with status-check querying
  • PR #2842 — Integrates review-bot-gate-helper into supervisor fast-path; related through shared helper script evolution

Suggested labels

bug

Poem

🤖 A bot gets rate-limited, the gate starts to fail,
But wait! A status check arrives in the mail.
No comment, but proof the bot did its thing—
The fallback says yes, let this PR take wing! ✅

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: implementing a status check fallback mechanism to handle rate-limited review bots in the review-bot-gate workflow.
Linked Issues check ✅ Passed The pull request fully implements the primary objective from issue #3005: adding a status check fallback for rate-limited bots and treating SUCCESS status checks as proof of review completion.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing the rate-limit fallback feature across the workflow and helper script; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/t3005-review-bot-gate-rate-limit

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 6, 2026
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 108 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Fri Mar 6 18:19:29 UTC 2026: Code review monitoring started
Fri Mar 6 18:19:29 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 108

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 108
  • VULNERABILITIES: 0

Generated on: Fri Mar 6 18:19:32 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the review-bot-gate workflow to prevent PRs from being blocked when AI review bots are rate-limited. It introduces a robust fallback mechanism that checks for successful GitHub commit status checks from known bots, ensuring that PRs can proceed even if bots cannot post full review comments. This change improves the reliability and efficiency of the automated review process by accommodating API rate limits gracefully.

Highlights

  • Rate-Limited Bot Fallback: Implemented a new mechanism where the review-bot-gate falls back to checking formal GitHub commit status checks when all review bots are rate-limited and post quota notices instead of actual reviews.
  • Status Check Validation: If any known bot (e.g., CodeRabbit) has posted a 'SUCCESS' status check on the PR's head commit, the gate now passes, acknowledging that the bot completed its analysis despite rate-limiting on comments.
  • New Helper Function: Added a new any_bot_has_success_status() function to the helper script, which queries GitHub API for commit statuses and check runs to identify successful bot analyses.
  • Updated Gate Logic: The PR gate logic order has been updated to prioritize a 'PASS' if bots are rate-limited but have successful status checks, before falling back to 'WAITING' if no such checks are found.
Changelog
  • .agents/scripts/review-bot-gate-helper.sh
    • Added the any_bot_has_success_status function to query GitHub for successful bot status checks.
    • Modified the do_check function to incorporate the new fallback logic for rate-limited bots.
    • Updated the do_list function to display information about the status check fallback.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/review-bot-gate.yml
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a fallback mechanism to check for bot success statuses when review comments indicate rate-limiting. The implementation is sound, and all original comments have been retained as they either align with the provided rules or address valid concerns not covered by the rules. My feedback includes suggestions to remove stderr suppression for better debuggability, optimize a loop for performance, and correct the handling of output streams.

Comment on lines +146 to +147
head_sha=$(gh pr view "$pr_number" --repo "$repo" \
--json headRefOid -q '.headRefOid' 2>/dev/null || echo "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Suppressing stderr with 2>/dev/null can hide important errors from the gh command, such as authentication failures or invalid repository details, making debugging difficult. It's better to let stderr be printed so that underlying issues are visible. The || echo "" construct will still prevent the script from exiting on failure and ensure head_sha is empty.

Suggested change
head_sha=$(gh pr view "$pr_number" --repo "$repo" \
--json headRefOid -q '.headRefOid' 2>/dev/null || echo "")
head_sha=$(gh pr view "$pr_number" --repo "$repo" \
--json headRefOid -q '.headRefOid' || echo "")
References
  1. Avoid blanket error suppression with 2>/dev/null to ensure underlying errors like authentication or system issues remain visible for debugging.

Comment on lines +154 to +156
statuses=$(gh api "repos/${repo}/commits/${head_sha}/statuses" \
--paginate --jq '.[] | select(.state == "success") | .context' \
2>/dev/null || echo "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

As with the previous gh command, suppressing stderr with 2>/dev/null can hide important API errors (e.g., authentication, rate limiting, or an invalid SHA). Removing it will improve debuggability by making these errors visible, while || echo "" will still handle the failure case gracefully.

Suggested change
statuses=$(gh api "repos/${repo}/commits/${head_sha}/statuses" \
--paginate --jq '.[] | select(.state == "success") | .context' \
2>/dev/null || echo "")
statuses=$(gh api "repos/${repo}/commits/${head_sha}/statuses" \
--paginate --jq '.[] | select(.state == "success") | .context' \
|| echo "")
References
  1. Avoid blanket error suppression with 2>/dev/null to ensure underlying errors like authentication or system issues remain visible for debugging.

Comment on lines +160 to +162
statuses=$(gh api "repos/${repo}/commits/${head_sha}/check-runs" \
--paginate --jq '.check_runs[] | select(.conclusion == "success") | .name' \
2>/dev/null || echo "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similarly, 2>/dev/null should be removed here to avoid masking potential errors from the GitHub API when fetching check-runs. This ensures that any issues with the API call are visible for easier debugging.

Suggested change
statuses=$(gh api "repos/${repo}/commits/${head_sha}/check-runs" \
--paginate --jq '.check_runs[] | select(.conclusion == "success") | .name' \
2>/dev/null || echo "")
statuses=$(gh api "repos/${repo}/commits/${head_sha}/check-runs" \
--paginate --jq '.check_runs[] | select(.conclusion == "success") | .name' \
|| echo "")
References
  1. Avoid blanket error suppression with 2>/dev/null to ensure underlying errors like authentication or system issues remain visible for debugging.

local bot bot_base
for bot in "${KNOWN_BOTS[@]}"; do
bot_base=$(echo "$bot" | tr '[:upper:]' '[:lower:]')
if echo "$statuses_lower" | grep -qi "$bot_base"; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using echo and grep inside a for loop is inefficient as it spawns new processes for each iteration. You can achieve the same result more efficiently by using Bash's built-in string matching capabilities, which avoids the overhead of external processes.

Suggested change
if echo "$statuses_lower" | grep -qi "$bot_base"; then
if [[ "$statuses_lower" == *"$bot_base"* ]]; then

# Show status check fallback info
echo ""
echo "Status check fallback (GH#3005):"
if any_bot_has_success_status "$pr_number" "$repo" 2>&1; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 2>&1 redirection sends the diagnostic message from any_bot_has_success_status (which is printed to stderr) to stdout. This mixes diagnostic output with the formatted report from do_list, and the message will not be indented correctly. It's better to let the diagnostic message be printed to stderr as intended by removing 2>&1. The if statement will still correctly evaluate the function's exit code.

Suggested change
if any_bot_has_success_status "$pr_number" "$repo" 2>&1; then
if any_bot_has_success_status "$pr_number" "$repo"; then

@marcusquinn marcusquinn merged commit 8caf94a into main Mar 6, 2026
38 of 39 checks passed
@marcusquinn marcusquinn deleted the bugfix/t3005-review-bot-gate-rate-limit branch March 6, 2026 18:24
marcusquinn added a commit that referenced this pull request Mar 7, 2026
…w-bot-gate-helper

Address PR #3006 review feedback (GH#3025):
- Remove 2>/dev/null from gh pr view, gh api statuses, and gh api
  check-runs calls in any_bot_has_success_status() — the || echo ""
  fallback handles failures gracefully while letting auth/network
  errors remain visible for debugging
- Remove 2>&1 from any_bot_has_success_status call in do_list() to
  prevent mixing diagnostic stderr with formatted report output
- Finding #4 (echo|grep -> bash built-in) was already addressed in
  the merged PR via bidirectional [[ ]] matching
marcusquinn added a commit that referenced this pull request Mar 7, 2026
…w-bot-gate-helper (#3039)

Address PR #3006 review feedback (GH#3025):
- Remove 2>/dev/null from gh pr view, gh api statuses, and gh api
  check-runs calls in any_bot_has_success_status() — the || echo ""
  fallback handles failures gracefully while letting auth/network
  errors remain visible for debugging
- Remove 2>&1 from any_bot_has_success_status call in do_list() to
  prevent mixing diagnostic stderr with formatted report output
- Finding #4 (echo|grep -> bash built-in) was already addressed in
  the merged PR via bidirectional [[ ]] matching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: review-bot-gate.yml fails when bots post rate-limit notices instead of reviews

1 participant