fix(grok): tolerate missing creditUsagePercent in billing API#8298
fix(grok): tolerate missing creditUsagePercent in billing API#8298choiwjun wants to merge 1 commit into
Conversation
SuperGrok unified billing sometimes omits creditUsagePercent on /billing?format=credits. Fall back to productUsage, used/monthlyLimit from default /billing, and 0% when weekly pool metadata is present.
|
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)
📝 WalkthroughWalkthroughGrok rate-limit fetching now supports multiple billing payload formats, including product usage, numeric money wrappers, sibling subscription tiers, and unified weekly metadata. It derives weekly usage from available counters, merges credits data with a default billing response when needed, and uses shared handling for HTTP, authorization, JSON, and network errors. Tests cover fallback requests, weekly reset and usage mapping, zero-usage metadata, and unavailable responses. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
Problem
Orca status bar Grok usage shows:
Grok billing response did not include credit usage.Root cause: SuperGrok unified billing (
/v1/billing?format=credits) sometimes omitscreditUsagePercentwhile still returning weekly period metadata. Orca treated that as unavailable.Fix
creditUsagePercentwhen presentproductUsage[].usagePercentsum/v1/billingand useused/monthlyLimitsubscriptionTierfrom response root when nested underconfigis absentTest plan
grok-fetcher.test.tscreditUsagePercentno longer errors