t2980: fix review-bot-gate to distinguish rate-limit notices from real reviews#2982
Conversation
…ws (#2980) When bots are rate-limited, they post quota/rate-limit notices instead of actual code reviews. The gate was counting these as valid reviews (PASS) because it only checked for comment existence, not content. Now both the helper script and CI workflow: - Base64-encode comment bodies to handle multi-line content correctly - Check each bot comment against known rate-limit patterns - Only count comments as real reviews if they don't match rate-limit patterns - Return WAITING (not PASS) when all bot comments are rate-limit notices - Show rate-limited bots separately in output and CI summary Tested against PR #2978 (rate-limited → WAITING) and PR #2933 (real review → PASS).
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
WalkthroughThis PR fixes a bug where review-bot-gate incorrectly treats rate-limit notices from bots as actual code reviews. Two new functions detect rate-limit patterns and validate that bot comments contain genuine reviews before counting them as passed gate checks. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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 |
🔍 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 05:17:14 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
|
Resolves #2980 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.agents/scripts/review-bot-gate-helper.sh (1)
86-97: Useprintfinstead ofechofor safer pattern matching.If
$bodyever starts with a dash (e.g.,-eor-n),echomay interpret it as an option, causing unexpected behavior. Usingprintf '%s'is more robust.🔧 Suggested improvement
is_rate_limit_comment() { # Check if a comment body matches any known rate-limit/quota pattern. # Returns 0 if the comment IS a rate-limit notice (not a real review). local body="$1" for pattern in "${RATE_LIMIT_PATTERNS[@]}"; do - if echo "$body" | grep -qi "$pattern"; then + if printf '%s' "$body" | grep -qi "$pattern"; then return 0 fi done return 1 }🤖 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 86 - 97, The function is_rate_limit_comment uses echo to pass $body to grep which can misinterpret leading dashes; update the body feeding to use printf '%s' "$body" when checking each RATE_LIMIT_PATTERNS entry so pattern matching is robust even if $body begins with '-' or contains backslashes; keep the loop over RATE_LIMIT_PATTERNS and the grep -qi check and preserve the same return values from is_rate_limit_comment..github/workflows/review-bot-gate.yml (1)
95-133: Sameprintfvsechoconsideration applies here.The inline
is_rate_limit_commentfunction has the same minor robustness concern as the helper script at line 99.Note on code duplication: These helper functions are intentionally mirrored from the shell script for workflow portability. This creates a maintenance burden — changes need to be synchronized between both files. Consider documenting this relationship in a comment.
🔧 Optional: add sync reminder comment
+ # Helper: check if a comment body is a rate-limit notice + # NOTE: Mirrored from .agents/scripts/review-bot-gate-helper.sh — keep in sync is_rate_limit_comment() { local body="$1" for pattern in "${RATE_LIMIT_PATTERNS[@]}"; do - if echo "$body" | grep -qi "$pattern"; then + if printf '%s' "$body" | grep -qi "$pattern"; then return 0 fi done return 1 } + # Helper: check if a bot has at least one real review (not rate-limited) + # NOTE: Mirrored from .agents/scripts/review-bot-gate-helper.sh — keep in sync bot_has_real_review() {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/review-bot-gate.yml around lines 95 - 133, The helper functions is_rate_limit_comment and bot_has_real_review use echo to emit/print values; replace those echo uses (e.g., echo "$body", echo "$encoded", echo "") with printf to avoid issues with leading hyphens, backslashes, or format-string interpretation and make the parsing robust, and add a short comment above these helpers noting they are mirrored from the shell script and must be kept in sync to reduce maintenance drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.agents/scripts/review-bot-gate-helper.sh:
- Around line 86-97: The function is_rate_limit_comment uses echo to pass $body
to grep which can misinterpret leading dashes; update the body feeding to use
printf '%s' "$body" when checking each RATE_LIMIT_PATTERNS entry so pattern
matching is robust even if $body begins with '-' or contains backslashes; keep
the loop over RATE_LIMIT_PATTERNS and the grep -qi check and preserve the same
return values from is_rate_limit_comment.
In @.github/workflows/review-bot-gate.yml:
- Around line 95-133: The helper functions is_rate_limit_comment and
bot_has_real_review use echo to emit/print values; replace those echo uses
(e.g., echo "$body", echo "$encoded", echo "") with printf to avoid issues with
leading hyphens, backslashes, or format-string interpretation and make the
parsing robust, and add a short comment above these helpers noting they are
mirrored from the shell script and must be kept in sync to reduce maintenance
drift.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dafe214d-9a5e-4b7a-bf67-474f66bcd2e0
📒 Files selected for processing (2)
.agents/scripts/review-bot-gate-helper.sh.github/workflows/review-bot-gate.yml



Summary
review-bot-gate-helper.shandreview-bot-gate.ymlto check comment content, not just comment existence, when determining if a bot has reviewed a PRWAITINGinstead of incorrectly returningPASSProblem
Closes #2980
When bots hit rate limits, they post notices like "Rate limit exceeded" or "You have reached your daily quota limit". The gate was counting these as valid reviews because it only checked whether a known bot username appeared in the commenter list — not what the comment actually said. This caused 12+ PRs with zero real reviews to show
PASS.Changes
.agents/scripts/review-bot-gate-helper.sh:RATE_LIMIT_PATTERNSarray with known rate-limit/quota message patternsis_rate_limit_comment()function to check if a comment body matches any rate-limit patternbot_has_real_review()function that fetches comment bodies (base64-encoded to handle multi-line content), decodes them, and checks each against rate-limit patternsdo_check()to validate comment content before counting a bot as having revieweddo_list()to show rate-limit status per bot.github/workflows/review-bot-gate.yml:rate_limited_botsoutput for visibilityTesting
Verified against real PRs:
WAITINGwith "Bots posted rate-limit notices only"PASSSummary by CodeRabbit
New Features
Bug Fixes