Skip to content

t1410: fix review-bot-gate status fallback for CodeRabbit context mismatch#3008

Merged
marcusquinn merged 2 commits intomainfrom
bugfix/review-bot-gate-coderabbit-match
Mar 6, 2026
Merged

t1410: fix review-bot-gate status fallback for CodeRabbit context mismatch#3008
marcusquinn merged 2 commits intomainfrom
bugfix/review-bot-gate-coderabbit-match

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Mar 6, 2026

Summary

  • Fix any_bot_has_success_status() in both .github/workflows/review-bot-gate.yml and .agents/scripts/review-bot-gate-helper.sh to use bidirectional prefix matching instead of grep
  • The grep -qi "coderabbitai" pattern from GH#3005 fails to match the status context CodeRabbit because coderabbitai is NOT a substring of coderabbit — the match direction was wrong
  • Replace with bash [[ "$bot_base" == "$ctx"* ]] || [[ "$ctx" == "$bot_base"* ]] which correctly matches coderabbitai against coderabbit (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 used grep -qi "$bot_base" where bot_base is coderabbitai (the bot login). CodeRabbit's commit status context is CodeRabbit, which lowercases to coderabbit. Since coderabbitai is NOT a substring of coderabbit, 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

    • Review gate now correctly recognizes successful bot checks even when status context names differ from bot names (bidirectional prefix matching), reducing false blocks on PRs.
  • Chores

    • Improved logging for status detection to show which context matched, and clearer messaging around commit-status handling during review checks.

@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dfc7c144-b4bd-46c8-b51f-349791709b4a

📥 Commits

Reviewing files that changed from the base of the PR and between f51a270 and fe3a074.

📒 Files selected for processing (2)
  • .agents/scripts/review-bot-gate-helper.sh
  • .github/workflows/review-bot-gate.yml

Walkthrough

Replaces 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

Cohort / File(s) Summary
Shell Script Gate Helper
.agents/scripts/review-bot-gate-helper.sh
Rewrote any_bot_has_success_status() to iterate status contexts (lowercased) and perform bidirectional prefix checks (context starts with bot_base OR bot_base starts with context); improved logging to include the matched context.
Workflow Gate Logic
.github/workflows/review-bot-gate.yml
Adjusted gate flow to use the updated helper logic (bidirectional prefix matching) when checking for bot SUCCESS statuses and emit logs showing the specific matched context; retained PR head SHA queries for statuses/check-runs.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

bug

Poem

🐇 A tiny bot and a status named strange,
Prefixes flexed so two names could arrange,
Logs now sing which context was true,
Gates open where success was due—
Small match, big sighs rearrange.

🚥 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 PR title directly and concisely describes the main fix: addressing the CodeRabbit context mismatch issue in the review-bot-gate status fallback logic.
Linked Issues check ✅ Passed The code changes fully implement the required fix: bidirectional prefix matching between bot names and status contexts now correctly matches 'coderabbit' against both 'coderabbitai' and 'CodeRabbit'.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the CodeRabbit status context mismatch across both the workflow and helper script, with no unrelated modifications detected.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/review-bot-gate-coderabbit-match

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2c3341c and 9a2cf0d.

📒 Files selected for processing (2)
  • .agents/scripts/review-bot-gate-helper.sh
  • .github/workflows/review-bot-gate.yml

@marcusquinn marcusquinn force-pushed the bugfix/review-bot-gate-coderabbit-match branch from 9a2cf0d to f51a270 Compare March 6, 2026 20:24
@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 20:25:24 UTC 2026: Code review monitoring started
Fri Mar 6 20:25:25 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 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
@marcusquinn marcusquinn force-pushed the bugfix/review-bot-gate-coderabbit-match branch from f51a270 to d28d266 Compare March 6, 2026 20:31
@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 20:31:33 UTC 2026: Code review monitoring started
Fri Mar 6 20:31:34 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 20:31:36 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 | 🟠 Major

Query 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 /statuses query is empty. This creates two reliability issues in this critical gate helper:

  1. 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.
  2. 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-runs unconditionally, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9a2cf0d and f51a270.

📒 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
@marcusquinn marcusquinn merged commit d8e5b54 into main Mar 6, 2026
1 check was pending
@marcusquinn marcusquinn deleted the bugfix/review-bot-gate-coderabbit-match branch March 6, 2026 20:34
@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 20:34:39 UTC 2026: Code review monitoring started
Fri Mar 6 20:34:40 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 20:34:42 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

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.

t1410: fix review-bot-gate status fallback: CodeRabbit context mismatch

1 participant