Skip to content

[Bug][Backend] rateLimitService.checkRateLimit uses '<' instead of '<=' causing off-by-one that blocks the Nth allowed request #2027

Description

@blurbeast

Issue #147

rateLimitService.checkRateLimit Uses '<' Instead of '<=' Causing Off-By-One That Blocks the Nth Allowed Request

  • Title: [Bug][Backend] rateLimitService.checkRateLimit uses '<' instead of '<=' causing off-by-one that blocks the Nth allowed request
  • Labels: bug, backend, good first issue
  • Location: backend/src/services/rateLimitService.ts:88
  • Description:
    In rateLimitService.checkRateLimit, the Redis Lua script INCR_AND_EXPIRE_SCRIPT increments the request counter before returning currentCount (so the 1st request returns 1, and the maxRequests-th request returns maxRequests). However, line 88 checks const allowed = currentCount < config.maxRequests;. When config.maxRequests = 5, the 5th request receives currentCount = 5, so 5 < 5 evaluates to false, rejecting the 5th request with HTTP 429.
  • Impact:
    Every rate limiter using rateLimitService.checkRateLimit permits maxRequests - 1 requests instead of maxRequests.
  • Suggested Fix:
    Change line 88 in backend/src/services/rateLimitService.ts from const allowed = currentCount < config.maxRequests; to const allowed = currentCount <= config.maxRequests;.

Activity

  1. added
    bugSomething isn't working
    backendIssues related to backend development
    on Oct 18, 2026
  2. ranjeet150 commented on Oct 18, 2026

    @ranjeet150

    Hello,

    I am interested in taking up "[Bug][Backend] rateLimitService.checkRateLimit uses '<' instead of '<=' causing off-by-one that blocks the Nth allowed request" and implementing a production-grade solution.

    I have reviewed the problem description and acceptance criteria for this issue. I have a clear, tested implementation ready with defensive error handling and 100% green CI proof.

    I will deliver a clean, well-tested, and production-ready PR promptly upon assignment. Kindly assign this issue to me.

    Thank you!

  3. tijanib141 commented on Oct 18, 2026

    @tijanib141

    @tijanib141 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    hi, please give me this, i can do this fast

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @tijanib141 to this issue.

  4. lancefair431-code commented on Oct 18, 2026

    @lancefair431-code

    @lancefair431-code has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I’d love to help out with this issue. I’ve checked the current codebase/documentation and know exactly what needs to be updated to make this clearer. I will ensure everything aligns perfectly with your existing contribution guidelines.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @lancefair431-code to this issue.

  5. Wittig18 commented on Oct 18, 2026

    @Wittig18

    @Wittig18 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    hey maintainer, i would love to work on this

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Wittig18 to this issue.

  6. shadrach68 commented on Oct 18, 2026

    @shadrach68

    @shadrach68 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello maintainer,

    I’m a Full Stack Blockchain, Mobile, and Software Engineer with experience building scalable and production ready applications.

    I’ve reviewed this particular issue and understand its requirements. If assigned, I’ll begin work immediately, provide regular updates, and deliver a clean, well-tested, and maintainable solution that meets the project’s standards.

    Looking forward to contributing.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @shadrach68 to this issue.

  7. bade2brazy commented on Oct 18, 2026

    @bade2brazy
    Contributor

    @bade2brazy has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    assign this issue to me

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @bade2brazy to this issue.

  8. moon-code12 commented on Oct 18, 2026

    @moon-code12

    @moon-code12 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello Maintainers, I would like to express my interest in working on this issue. I have reviewed the issue description and understand the problem that needs to be addressed. My approach will be to investigate the existing codebase, identify the root cause, and implement a solution that follows the project's existing architecture and coding standards.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @moon-code12 to this issue.

  9. Muyideen-js commented on Oct 18, 2026

    @Muyideen-js

    @Muyideen-js has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi, I can fix this

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Muyideen-js to this issue.

  10. innocentharuna commented on Oct 18, 2026

    @innocentharuna

    @innocentharuna has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    hey maintainer, please kindly assign this to me, i can surely fix it

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @innocentharuna to this issue.

  11. christianezeanya commented on Oct 18, 2026

    @christianezeanya

    @christianezeanya has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello Maintainer, I've reviewed the issue description and I'm confident I can work on it effectively. Please assign it to me.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @christianezeanya to this issue.

  12. Teejay2696 commented on Oct 18, 2026

    @Teejay2696

    @Teejay2696 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi maintainer, I can fix this kindly assign

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Teejay2696 to this issue.

  13. CollinsKRO commented on Oct 18, 2026

    @CollinsKRO

    @CollinsKRO has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi Maintainer, I can fix this pls assign. ETA 5hrs

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @CollinsKRO to this issue.

  14. VeronicDev commented on Oct 18, 2026

    @VeronicDev

    @VeronicDev has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello Maintainer, I can fix this please assign.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @VeronicDev to this issue.

  15. drips-wave commented on Oct 18, 2026

    @drips-wave

    Congratulations, @bade2brazy! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @bade2brazy: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  16. bade2brazy commented on Oct 18, 2026

    @bade2brazy
    Contributor

    Resolved in PR #2032. Fixed off-by-one by changing < to <= in rateLimitService.checkRateLimit and updated unit tests.

  17. drips-wave commented on Oct 18, 2026

    @drips-wave

    This issue has been completed by @bade2brazy as part of the Stellar Wave Program's 10th Wave 🥳

    😎 @bade2brazy: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendIssues related to backend developmentbugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions