Repository navigation
fix(web): keep developer videos API paging from returning 500 - #3571
Open
AryaKesharwani wants to merge 2 commits into
Open
AryaKesharwani wants to merge 2 commits into
AryaKesharwani wants to merge 2 commits into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
| ) { | ||
| return { | ||
| limit: Math.min( | ||
| Math.max(1, Math.trunc(Number(limit)) || DEFAULT_LIMIT), |
Contributor
There was a problem hiding this comment.
Small limits return extra videos
parseDeveloperListParams returns 50 for limit=0.5 or limit=-0.5, rather than the intended minimum of 1. Truncating first produces zero, so || DEFAULT_LIMIT selects 50 before the lower bound applies.
Apply the default before truncating, then clamp the result. This keeps the existing default for an explicit zero while giving nonzero fractions below 1 the intended minimum.
Suggested change
| Math.max(1, Math.trunc(Number(limit)) || DEFAULT_LIMIT), | |
| Math.max(1, Math.trunc(Number(limit) || DEFAULT_LIMIT)), |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/lib/developer-list-params.ts
Line: 10
Comment:
**Small limits return extra videos**
`parseDeveloperListParams` returns 50 for `limit=0.5` or `limit=-0.5`, rather than the intended minimum of 1. Truncating first produces zero, so `|| DEFAULT_LIMIT` selects 50 before the lower bound applies.
Apply the default before truncating, then clamp the result. This keeps the existing default for an explicit zero while giving nonzero fractions below 1 the intended minimum.
```suggestion
Math.max(1, Math.trunc(Number(limit) || DEFAULT_LIMIT)),
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Author
There was a problem hiding this comment.
Fixed in 8a5cbdd: limit=0.5 and limit=-0.5 now return 1 video, and both cases are in the test.
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.
GET /api/developer/v1/videosreturned 500 forlimit=5.5,offset=2.5oroffset=99999999999999999999, because the values were clamped but never truncated or bounded, and MySQL rejects them inLIMIT/OFFSET.Move the parsing into
parseDeveloperListParams: truncate to whole numbers, keep the existing default (50) and cap (100) forlimit, floorlimitat 1 and boundoffsetto0..Number.MAX_SAFE_INTEGER.limit=0/limit=abclimit=500limit=5.5offset=2.5offset=99999999999999999999limit=-1Validation: new
developer-list-params.test.tspasses. Verified in a local self-hosted web build with a seeded developer app and secret key: the three failing queries returned 500 onmainand 200 after. Biome check passes.Closes #3568.
The PR appears safe to merge, with a non-blocking limit edge case worth fixing.
Findings
Fix with agent prompt
Summary
Moves developer video paging into
parseDeveloperListParams.Review used code inspection; tests were not run.
Reviews (1) · Last reviewed commit: "fix(web): keep developer videos API pagi..." · Reviewed by Greptile