Repository navigation
Conversation
…Software#3568) GET /api/developer/v1/videos returned 500 Internal Server Error when limit or offset were fractional (e.g. limit=5.5, offset=2.5) or oversized because values passed directly into MySQL LIMIT/OFFSET without integer coercion or bounds. Added parseDeveloperVideosPagination in apps/web/lib/developer-pagination.ts to floor fractional inputs, enforce valid positive ranges (limit: 1..100, offset: 0..1,000,000,000), and safely fall back to defaults (50, 0). Added unit tests covering boundaries and edge cases. Closes CapSoftware#3568
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3568
Linear: CAP-958
GET /api/developer/v1/videosreturned500 Internal Server Errorwhenlimitoroffsetwere passed fractional numbers (e.g.limit=5.5,offset=2.5) or oversized integers due to MySQL syntax errors inLIMITandOFFSET.Root Cause
apps/web/app/api/developer/v1/[...route]/videos.tspassedNumber(c.req.query("limit"))andNumber(c.req.query("offset"))directly into Drizzle's.limit(...)and.offset(...)without integer rounding or offset upper bounds.Changes
apps/web/lib/developer-pagination.tsprovidingparseDeveloperVideosPagination:Math.floor).limitbetween 1 and 100 with default 50 (DEFAULT_DEVELOPER_API_LIMIT,MAX_DEVELOPER_API_LIMIT).offsetbetween 0 and 1,000,000,000 (MAX_DEVELOPER_API_OFFSET) with default 0.parseDeveloperVideosPaginationinvideos.ts.apps/web/__tests__/unit/developer-videos-pagination.test.tscovering missing/empty params, valid integers, fractional flooring, non-numeric fallbacks, and oversized bounds.Test plan
bun test apps/web/__tests__/unit/developer-videos-pagination.test.ts(5 pass, 10 assertions)bun test apps/web/__tests__/unit/cap-pagination.test.ts(4 pass, 15 assertions)bun test apps/web/__tests__/unit/pagination-params.test.ts(6 pass, 23 assertions)limit=5.5floors to 5,offset=2.5floors to 2, and oversized offset is bounded cleanly, preventing MySQL 500 errors.

Confidence Score: 5/5
The PR appears safe to merge.Summary
The PR prevents invalid pagination values from reaching the developer video query.
No actionable issues were found. Tests were inspected but not run during this review.
Reviews (1) · Last reviewed commit: "fix(web): validate and bound developer a..." · Reviewed by Greptile