fix: prevent negative wait time in rate limit error message#28765
fix: prevent negative wait time in rate limit error message#28765romitg2 merged 2 commits intocalcom:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe pull request modifies rate limit error handling logic and adds test coverage. The implementation adjusts how computed wait times are calculated when a rate limit check fails, ensuring the value doesn't become negative when the reset timestamp has already elapsed. A corresponding unit test case verifies this behavior by mocking a rate limiter with a past reset timestamp and confirming the error message reports a minimum of zero seconds. 🚥 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 |
What does this PR do?
Fixes #28764
This PR prevents negative wait times from being displayed in the rate limit error message.
Previously, if the
resettimestamp was in the past, the computed wait time could become negative, leading to messages like:"Rate limit exceeded. Try again in -5 seconds."
This PR clamps the value to a minimum of
0to ensure correct and user-friendly output.Visual Demo (For contributors especially)
N/A — this is a logic-level fix and does not require UI interaction.
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Mock a rate limiter response where:
success = falsereset < Date.now()Call:
Verify: