Skip to content

fix(search): enforce pagination bounds on search list endpoints - #1354

Open
DevALVIN-24 wants to merge 1 commit into
rinafcode:mainfrom
DevALVIN-24:fix/search-pagination-bounds
Open

fix(search): enforce pagination bounds on search list endpoints#1354
DevALVIN-24 wants to merge 1 commit into
rinafcode:mainfrom
DevALVIN-24:fix/search-pagination-bounds

Conversation

@DevALVIN-24

Copy link
Copy Markdown

closes #1309

Overview

This PR enforces validation and bounding for pagination parameters in the search endpoint, preventing clients from requesting an unbounded number of rows (which poses a memory, DoS, and performance risk).

Changes Made

  • Created PaginationDto: Added a new DTO in src/search/dto/pagination.dto.ts using class-validator to enforce pagination constraints and type conversion.
  • Enforced Constraints:
    • page: Minimum is 1. Default is 1.
    • limit: Minimum is 1. Maximum is clamped at 100. Default is 20.
    • Invalid values (negative, zero, non-numeric strings, or limits over 100) are automatically rejected with a 400 Bad Request through NestJS's ValidationPipe combined with @IsInt(), @Min(), @Max(), and @Type(() => Number).
  • Updated Controller: Replaced raw string pagination parsing in src/search/search.controller.ts with the new validated PaginationDto.
  • Swagger Documentation: Updated @ApiQuery to properly reflect and document the maximum page size (100) alongside default limits.

Testing/Acceptance Criteria Verified

  • Requesting an oversized limit (e.g., limit=200) is rejected with a 400 Bad Request.
  • Passing invalid negative or non-numeric limits/pages fails with a 400 Bad Request.
  • Requests missing limit or page succeed by automatically applying the 1 (page) and 20 (limit) defaults.

@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@DevALVIN-24 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Well done on the job done so far!
Kindly fix workflow to pass

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce pagination bounds on search list endpoints

2 participants