fix(core): classify Claude usage-limit errors as rate limits#1761
fix(core): classify Claude usage-limit errors as rate limits#1761k4n4lm00n wants to merge 1 commit into
Conversation
Claude's 5-hour subscription cap surfaces as "You've hit your limit · resets <time>" (and "usage limit" when org overage is disabled). Neither matched the rate-limit branch in classifyAndFormatError, so users hit the generic "An unexpected error occurred" fallback instead of a clear message. Match both phrasings case-insensitively alongside "rate limit" and echo the reset time when present, e.g. "⚠️ AI usage limit reached (resets 4:50pm (UTC)). Please wait and try again." Applies to every platform. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughError classification for rate and usage limits now detects multiple phrases with case-insensitive matching and extracts optional reset timestamps from error messages. Test suite expanded to cover Claude subscription limits, reset-time variants, and abbreviated time formatting. ChangesRate Limit Error Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Summary
/resetattempts, when the user just needs to wait for the reset.classifyAndFormatError(core) now recognises Claude usage-cap phrasings and surfaces a clear message with the reset time. Applies to every platform.error-formatter.ts(+ its tests). No provider, adapter, workflow, or schema changes.Provenance
Proudly built with and by Archon and Claude Code, with a pinch of human experience steering the wheel. 🤖🧂
Why this is needed
Archon speaks to users through chat (Zulip, Slack, Telegram, …) where there are no logs to open — the bot's reply is the entire error surface.⚠️ Claude authentication expired. Run
classifyAndFormatErroris the single place that turns raw provider/SDK errors into human guidance, and it already does this for several cases: e.g. an expired Claude auth/OAuth token becomes "/login…" instead of an opaque failure, telling the user exactly how to recover.The gap this PR closes sits right next to that case. Claude's 5-hour usage cap surfaces as⚠️ An unexpected error occurred. Try /reset…" — which reads like a crash and triggers
"You've hit your limit · resets <time>"(and"usage limit"when org overage is disabled). None of those phrasings matched the existing rate-limit branch, so they fell through to the catch-all "/resetattempts that cannot help. We now match those phrasings (case-insensitively) alongside"rate limit"and echo the reset time.UX Journey
Before
After
Label Snapshot
risk: lowsize: XScorecore:error-formatterChange Metadata
bugcoreLinked Issue
Validation Evidence (required)
Security Impact (required)
Compatibility / Migration
Human Verification (required)
classifyAndFormatError→⚠️ AI usage limit reached (resets 4:50pm (UTC)). Please wait and try again.; generic/unrelated errors still fall through unchanged.Side Effects / Blast Radius (required)
error-formatter.tsat 100% test coverage (57 cases).Rollback Plan (required)
Risks and Mitigations
Summary by CodeRabbit
Bug Fixes