Skip to content

fix(moderation): Enforce pagination bounds on content-reports list endpoint (#1306) - #1340

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
boalambo:fix/content-reports-pagination-bounds-1306
Aug 26, 2026
Merged

fix(moderation): Enforce pagination bounds on content-reports list endpoint (#1306)#1340
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
boalambo:fix/content-reports-pagination-bounds-1306

Conversation

@boalambo

Copy link
Copy Markdown
Contributor

Summary

Enforces sane pagination bounds on src/moderation/reports/content-reports.controller.ts's list endpoint, so a client can no longer request an unbounded number of rows (memory/DoS and performance risk) or pass negative/non-numeric pagination values.

Closes #1306

Changes

  • dto/list-content-reports-query.dto.ts
    • Replaced the unbounded limit field with validated page and limit fields using @IsInt, @Min, @Max from class-validator.
    • limit is capped at MAX_PAGE_SIZE (100) and defaults to DEFAULT_PAGE_SIZE (10) when omitted.
    • page defaults to 1 and must be a positive integer.
    • Both constants are pulled from the shared APP_CONSTANTS for consistency with the rest of the codebase.
    • Added JSDoc documenting the default and maximum page size.
  • content-reporting.service.ts
    • Computes skip from page/limit and passes both take/skip to the repository query, replacing the old query.limit ?? 50 fallback that had no upper bound.

Verification

  • npm run typecheck passes with no errors.
  • Confirmed ListContentReportsQueryDto is already wired into the controller's listReports handler via @Query(), so validation runs through the app's global ValidationPipe.
  • Confirmed DEFAULT_PAGE_SIZE (10) and MAX_PAGE_SIZE (100) exist in src/common/constants/app.constants.ts.

Acceptance criteria

  • ✅ Requesting an oversized limit is rejected with 400 (@Max(MAX_PAGE_SIZE)).
  • ✅ Invalid pagination values (negative, zero, non-numeric) return 400 (@IsInt, @Min(1)).
  • ✅ A default page size (10) applies when parameters are omitted.

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@boalambo 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

Thank you for contributing to the project

@RUKAYAT-CODER
RUKAYAT-CODER merged commit caeb64c into rinafcode:main Aug 26, 2026
3 checks passed
@boalambo

Copy link
Copy Markdown
Contributor Author

Thank you for contributing to the project

Thank you for always, so much grateful. God bless you ma

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 content-reports list endpoints

2 participants