[Backend] Enforce positive integer bounds and max limit cap on pagination query parameters
Overview
Several list endpoints in backend/src/controllers/stream.controller.ts and backend/src/routes/v1/events.routes.ts parse page and limit from req.query using parseInt, which can produce NaN, negative numbers, or unbounded limits.
Problem
- Passing
?limit=-5or?limit=999999can cause Prisma query errors or excessive memory usage on large datasets.
Proposed Changes
- Create a reusable
parsePagination(query, { defaultLimit = 20, maxLimit = 100 })helper inbackend/src/validators/stream.validator.ts. - Clamp
page >= 1and1 <= limit <= maxLimit, returning a400 Bad Requesterror when non-numeric strings are provided.
Acceptance Criteria
- [ ] Negative, zero, or non-integer
page/limitvalues return a clean 400 validation error. - [ ] Requests exceeding
maxLimit(100) are capped or rejected consistently. - [ ] Unit tests added in
backend/tests/unit/validation.test.ts.
@Holer8 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hello, I’ve gone through the requirements and I’m confident I can implement a proper solution that matches the acceptance criteria. Kindly assign this issue to me.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Holer8 to this issue.
@Yilkash has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Can i work on this?
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Yilkash to this issue.
Congratulations, @Yilkash! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.
🧑💻 @Yilkash: 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 🌊
🎉 This issue has been marked as completed on GrantFox!
@Yilkash's PR #1679 was approved and merged by @blurbeast.
🏆 @Yilkash: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (414 total points). Track your full progress on GrantFox.
👏 Great work, @Yilkash! Keep contributing to LabsCrypt.
This issue has been completed by @Yilkash as part of the Stellar Wave Program's 10th Wave 🥳
😎 @Yilkash: 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.