fix: classify G1 credit exhaustion as quota#591
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (1)
🔇 Additional comments (2)
Walkthrough
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
🚥 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. 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 |
Greptile SummaryThis PR maps the
Confidence Score: 4/5Safe to merge; the classification logic is correct and the ordering of checks ensures G1 credit exhaustion is never mistakenly mapped to MODEL_CAPACITY_EXHAUSTED. The new reason-switch case and message-scan branch both work correctly for the intended Gemini/Antigravity 429 payload. The only gap is that the human-readable src/plugin/accounts.test.ts — the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[parseRateLimitReason called
reason, message, status] --> B{status 529 or 503?}
B -->|Yes| C[MODEL_CAPACITY_EXHAUSTED]
B -->|No| D{status 500?}
D -->|Yes| E[SERVER_ERROR]
D -->|No| F{reason present?}
F -->|Yes| G{reason.toUpperCase}
G -->|QUOTA_EXHAUSTED| H[QUOTA_EXHAUSTED]
G -->|INSUFFICIENT_G1_CREDITS_BALANCE new case| H
G -->|RATE_LIMIT_EXCEEDED| I[RATE_LIMIT_EXCEEDED]
G -->|MODEL_CAPACITY_EXHAUSTED| C
G -->|no match| J
F -->|No| J{message present?}
J -->|Yes| K{includes insufficient_g1_credits_balance or g1 credits balance? new}
K -->|Yes| H
K -->|No| L{includes capacity / overloaded / resource exhausted?}
L -->|Yes| C
L -->|No| M{includes per minute / rate limit / too many requests?}
M -->|Yes| I
M -->|No| N{includes exhausted / quota?}
N -->|Yes| H
N -->|No| O{status 429?}
J -->|No| O
O -->|Yes| P[UNKNOWN]
O -->|No| P
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[parseRateLimitReason called
reason, message, status] --> B{status 529 or 503?}
B -->|Yes| C[MODEL_CAPACITY_EXHAUSTED]
B -->|No| D{status 500?}
D -->|Yes| E[SERVER_ERROR]
D -->|No| F{reason present?}
F -->|Yes| G{reason.toUpperCase}
G -->|QUOTA_EXHAUSTED| H[QUOTA_EXHAUSTED]
G -->|INSUFFICIENT_G1_CREDITS_BALANCE new case| H
G -->|RATE_LIMIT_EXCEEDED| I[RATE_LIMIT_EXCEEDED]
G -->|MODEL_CAPACITY_EXHAUSTED| C
G -->|no match| J
F -->|No| J{message present?}
J -->|Yes| K{includes insufficient_g1_credits_balance or g1 credits balance? new}
K -->|Yes| H
K -->|No| L{includes capacity / overloaded / resource exhausted?}
L -->|Yes| C
L -->|No| M{includes per minute / rate limit / too many requests?}
M -->|Yes| I
M -->|No| N{includes exhausted / quota?}
N -->|Yes| H
N -->|No| O{status 429?}
J -->|No| O
O -->|Yes| P[UNKNOWN]
O -->|No| P
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/plugin/accounts.ts:71-73
**Untested branch: `"g1 credits balance"` substring**
The `|| lower.includes("g1 credits balance")` arm is never exercised by any test. The new test only exercises the `"insufficient_g1_credits_balance"` arm (because the JSON payload is lowercased as `…"reason":"insufficient_g1_credits_balance"…`). A message like `"Your G1 credits balance is insufficient"` would hit the human-readable branch, but if that format ever diverges from expectations there's no safety net to catch a regression.
Reviews (1): Last reviewed commit: "fix: classify G1 credit exhaustion as qu..." | Re-trigger Greptile |
| if (lower.includes("insufficient_g1_credits_balance") || lower.includes("g1 credits balance")) { | ||
| return "QUOTA_EXHAUSTED"; | ||
| } |
There was a problem hiding this comment.
Untested branch:
"g1 credits balance" substring
The || lower.includes("g1 credits balance") arm is never exercised by any test. The new test only exercises the "insufficient_g1_credits_balance" arm (because the JSON payload is lowercased as …"reason":"insufficient_g1_credits_balance"…). A message like "Your G1 credits balance is insufficient" would hit the human-readable branch, but if that format ever diverges from expectations there's no safety net to catch a regression.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/plugin/accounts.ts
Line: 71-73
Comment:
**Untested branch: `"g1 credits balance"` substring**
The `|| lower.includes("g1 credits balance")` arm is never exercised by any test. The new test only exercises the `"insufficient_g1_credits_balance"` arm (because the JSON payload is lowercased as `…"reason":"insufficient_g1_credits_balance"…`). A message like `"Your G1 credits balance is insufficient"` would hit the human-readable branch, but if that format ever diverges from expectations there's no safety net to catch a regression.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
INSUFFICIENT_G1_CREDITS_BALANCEasQUOTA_EXHAUSTED.RESOURCE_EXHAUSTEDpayload.Closes #590.
Validation
Result: 35 test files passed, 997 tests passed.