t1410: fix review-bot-gate status fallback for CodeRabbit context mismatch#3008
t1410: fix review-bot-gate status fallback for CodeRabbit context mismatch#3008marcusquinn merged 2 commits intomainfrom
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughReplaces the previous substring-only status matching with bidirectional, case-insensitive prefix matching between bot base names and status contexts in the review-bot gate helper and workflow; updates logging to report the matched context when a SUCCESS status is found. Changes
Sequence Diagram(s)sequenceDiagram
participant Workflow as Review Bot Workflow
participant Helper as review-bot-gate-helper.sh
participant GH_PR as GitHub PR API
participant GH_Status as GitHub Statuss/Check-runs API
participant Gate as Gate Decision
Workflow->>Helper: invoke any_bot_has_success_status(pr_number)
Helper->>GH_PR: get PR head SHA
GH_PR-->>Helper: return SHA
Helper->>GH_Status: fetch commit statuses & check-runs for SHA
GH_Status-->>Helper: return contexts & states
Helper->>Helper: normalize contexts (lowercase)
Helper->>Helper: for each bot_base: check (context startsWith bot_base) OR (bot_base startsWith context)
alt matching SUCCESS found
Helper->>Workflow: report matched context and SUCCESS
Workflow->>Gate: PASS (status fallback)
else no match
Helper->>Workflow: report no matching SUCCESS
Workflow->>Gate: CONTINUE/FAIL (rate-limit path)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.agents/scripts/review-bot-gate-helper.sh:
- Around line 167-169: The fallback combined-status lookup using the gh api call
that populates the statuses variable only fetches the first page; update the gh
api invocation that queries "repos/${repo}/commits/${head_sha}/status" to
include pagination (use --paginate and per_page=100) so all status pages are
retrieved and filtered, and apply the same change to the corresponding call in
the review-bot-gate.yml workflow to avoid missing contexts when >30 statuses
exist.
In @.github/workflows/review-bot-gate.yml:
- Around line 155-165: The workflow job lacks the "statuses: read" permission
required for the commit-status API call used in any_bot_has_success_status (the
gh api "repos/${REPO}/commits/${head_sha}/status" call); update the job-level
permissions to include statuses: read alongside existing contents: read and
pull-requests: read so the gh api call can succeed when other permissions are
explicitly set.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b2ffc980-4abe-45a8-983e-b84ee8d2ed1d
📒 Files selected for processing (2)
.agents/scripts/review-bot-gate-helper.sh.github/workflows/review-bot-gate.yml
9a2cf0d to
f51a270
Compare
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Mar 6 20:25:27 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
The any_bot_has_success_status() function from GH#3005 used grep to match bot login names (e.g., 'coderabbitai') against commit status context names (e.g., 'CodeRabbit'). This failed because 'coderabbitai' is not a substring of 'coderabbit' — the match direction was wrong. Replace grep with bidirectional bash prefix matching: either string may be a prefix of the other. This correctly matches 'coderabbitai' (bot login) against 'coderabbit' (status context lowercased from 'CodeRabbit'), and handles all other bot name variations. Also add 'statuses: read' permission to the workflow job, required for the commit status API call added in GH#3005. Fixes #3007
f51a270 to
d28d266
Compare
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Mar 6 20:31:36 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.agents/scripts/review-bot-gate-helper.sh (1)
154-186:⚠️ Potential issue | 🟠 MajorQuery both current and historical status endpoints separately, then merge both for bot detection.
The current logic short-circuits: it only checks check-runs if the initial
/statusesquery is empty. This creates two reliability issues in this critical gate helper:
- Stale success match:
/statuses(plural) returns the full history in reverse chronological order. A context may have an older successful entry that was later updated to failure—this code would still match the old success.- Missed check-runs: If any unrelated CI status succeeded, the entire check-runs endpoint is skipped, missing a bot signal that exists only in check-runs.
Use
/status(singular, combined view showing latest per-context state), query/check-runsunconditionally, then merge both before the prefix match.🔧 Proposed fix
- local statuses - statuses=$(gh api "repos/${repo}/commits/${head_sha}/statuses" \ - --paginate --jq '.[] | select(.state == "success") | .context' \ - 2>/dev/null || echo "") - - if [[ -z "$statuses" ]]; then - # Also check the combined status endpoint (check runs) - statuses=$(gh api "repos/${repo}/commits/${head_sha}/check-runs" \ - --paginate --jq '.check_runs[] | select(.conclusion == "success") | .name' \ - 2>/dev/null || echo "") - fi + local statuses check_runs + statuses=$(gh api "repos/${repo}/commits/${head_sha}/status?per_page=100" \ + --paginate --jq '.statuses[] | select(.state == "success") | .context' \ + 2>/dev/null || echo "") + check_runs=$(gh api "repos/${repo}/commits/${head_sha}/check-runs?per_page=100" \ + --paginate --jq '.check_runs[] | select(.conclusion == "success") | .name' \ + 2>/dev/null || echo "") + statuses=$(printf '%s\n%s\n' "$statuses" "$check_runs" | grep -v '^$' || true)Per coding guidelines (
.agents/scripts/*.sh): automation scripts must prioritize reliability and robustness in gate decisions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.agents/scripts/review-bot-gate-helper.sh around lines 154 - 186, The current logic sets statuses from "repos/${repo}/commits/${head_sha}/statuses" and skips querying check-runs when that result is non-empty; change to always fetch the combined status endpoint "repos/${repo}/commits/${head_sha}/status" (singular) to get the latest per-context state, always fetch "repos/${repo}/commits/${head_sha}/check-runs" as well, merge both result streams into a single deduplicated, lowercased list (assign back to statuses or statuses_lower), then proceed with the existing KNOWN_BOTS / bot_base / ctx prefix-matching loop using the merged list so both check-runs and combined statuses are considered reliably for commit ${head_sha} detection.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In @.agents/scripts/review-bot-gate-helper.sh:
- Around line 154-186: The current logic sets statuses from
"repos/${repo}/commits/${head_sha}/statuses" and skips querying check-runs when
that result is non-empty; change to always fetch the combined status endpoint
"repos/${repo}/commits/${head_sha}/status" (singular) to get the latest
per-context state, always fetch "repos/${repo}/commits/${head_sha}/check-runs"
as well, merge both result streams into a single deduplicated, lowercased list
(assign back to statuses or statuses_lower), then proceed with the existing
KNOWN_BOTS / bot_base / ctx prefix-matching loop using the merged list so both
check-runs and combined statuses are considered reliably for commit ${head_sha}
detection.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c25b2fc6-1a3d-4005-ab62-ae4e25180cf8
📒 Files selected for processing (2)
.agents/scripts/review-bot-gate-helper.sh.github/workflows/review-bot-gate.yml
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/review-bot-gate.yml
…heck-runs Address CodeRabbit CHANGES_REQUESTED on PR #3008: - Switch from /statuses (plural, full history) to /status (singular, latest per-context state) to avoid stale-success matches - Add ?per_page=100 pagination to handle repos with >30 statuses - Always fetch check-runs unconditionally instead of short-circuiting when statuses are non-empty, then merge both streams - statuses: read permission already present in workflow (line 44) GH#3007
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Mar 6 20:34:42 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|



Summary
any_bot_has_success_status()in both.github/workflows/review-bot-gate.ymland.agents/scripts/review-bot-gate-helper.shto use bidirectional prefix matching instead ofgrepgrep -qi "coderabbitai"pattern from GH#3005 fails to match the status contextCodeRabbitbecausecoderabbitaiis NOT a substring ofcoderabbit— the match direction was wrong[[ "$bot_base" == "$ctx"* ]] || [[ "$ctx" == "$bot_base"* ]]which correctly matchescoderabbitaiagainstcoderabbit(and all other bot name variations)Problem
PR #3006 (GH#3005) added
any_bot_has_success_status()as a fallback when bots are rate-limited. However, the function usedgrep -qi "$bot_base"wherebot_baseiscoderabbitai(the bot login). CodeRabbit's commit status context isCodeRabbit, which lowercases tocoderabbit. Sincecoderabbitaiis NOT a substring ofcoderabbit, the grep fails and the status fallback never triggers.Verification
After merge, re-run the "Wait for AI Review Bots" check on PRs #2989 and #2979 to confirm the status fallback passes the gate.
Closes #3007
Summary by CodeRabbit
Bug Fixes
Chores