Skip to content

fix(api): robust validation and bounds clamping for limit and offset parameters #25.#56

Open
Vedant4102004 wants to merge 2 commits into
AditthyaSS:mainfrom
Vedant4102004:bug/fix-pagination-bounds
Open

fix(api): robust validation and bounds clamping for limit and offset parameters #25.#56
Vedant4102004 wants to merge 2 commits into
AditthyaSS:mainfrom
Vedant4102004:bug/fix-pagination-bounds

Conversation

@Vedant4102004
Copy link
Copy Markdown
Contributor

💡 Problem Description

The GET /api/models route was directly consuming uncoerced strings from query parameters. Passing alphanumeric payloads (undefined, abc), negative numbers, or massive thresholds caused runtime engine errors inside Prisma or unexpected application behaviors.

🛠️ Proposed Solution

  • Implemented deterministic fallback protection using strict constants (MAX_LIMIT = 50, DEFAULT_LIMIT = 10, DEFAULT_OFFSET = 0).
  • Implemented explicit isNaN() guards on parseInt executions to prevent malformed text vectors from passing to database utilities.
  • Implemented parameter clamping limits ensuring neither values evaluate beneath 0 or bypass the protection ceiling.

Closes #25

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

@Vedant4102004 is attempting to deploy a commit to the aditthyass' projects Team on Vercel.

A member of the Team first needs to authorize it.

@AditthyaSS
Copy link
Copy Markdown
Owner

Hey @Vedant4102004 , thank you for the contribution

I noticed that there are merge conflicts in this PR

Please sync your branch with the latest main branch, resolve the conflicts, and push the updated changes. Once the conflicts are resolved, I will continue with the review process

Let me know if you need any assistance while resolving them. Thanks again for the contribution

@Vedant4102004
Copy link
Copy Markdown
Contributor Author

Hi @AditthyaSS ! Thank you for the update.

I have synced my local branch with the latest main changes, successfully resolved the merge conflicts inside src/app/api/models/route.ts, and pushed the clean logic stack.

The validation, isNaN() guards, and deterministic boundary clamping limits for both limit and offset are now cleanly integrated. Please review it whenever you get a chance! 🙌

@Vedant4102004
Copy link
Copy Markdown
Contributor Author

Hey @AditthyaSS I have synced my local branch with the latest main changes, successfully resolved the merge conflicts inside src/app/api/models/route.ts, and pushed the clean logic stack. you can check it and merge it

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG/ROBUSTNESS] GET /api/models API Route Crashes on Invalid Pagination and Limit Query Parameters

2 participants