Skip to content

fix(web): keep developer videos API paging from returning 500 - #3571

Open
AryaKesharwani wants to merge 2 commits into
CapSoftware:mainfrom
AryaKesharwani:fix/developer-api-list-params
Open

AryaKesharwani wants to merge 2 commits into
CapSoftware:mainfrom
AryaKesharwani:fix/developer-api-list-params

Conversation

@AryaKesharwani

@AryaKesharwani AryaKesharwani commented Oct 29, 2026 •

Copy link
Copy Markdown

GET /api/developer/v1/videos returned 500 for limit=5.5, offset=2.5 or offset=99999999999999999999, because the values were clamped but never truncated or bounded, and MySQL rejects them in LIMIT/OFFSET.

Move the parsing into parseDeveloperListParams: truncate to whole numbers, keep the existing default (50) and cap (100) for limit, floor limit at 1 and bound offset to 0..Number.MAX_SAFE_INTEGER.

Query Before After
none / limit=0 / limit=abc 50 items, 200 unchanged
limit=500 100, 200 unchanged
limit=5.5 500 5 items, 200
offset=2.5 500 offset 2, 200
offset=99999999999999999999 500 empty page, 200
limit=-1 200 1 item, 200

Validation: new developer-list-params.test.ts passes. Verified in a local self-hosted web build with a seeded developer app and secret key: the three failing queries returned 500 on main and 200 after. Biome check passes.

Closes #3568.

RetriggerView in GreptileConfidence Score: 4/5

The PR appears safe to merge, with a non-blocking limit edge case worth fixing.

Findings

  1. P2 Small limits return extra videos ▶
Fix with agent prompt
### Issue 1
apps/web/lib/developer-list-params.ts:10
`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.

Summary

Moves developer video paging into parseDeveloperListParams.

  • Developer video lists now use bounded whole-number paging values.

Review used code inspection; tests were not run.

Reviews (1) · Last reviewed commit: "fix(web): keep developer videos API pagi..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Oct 29, 2026 10:28pm UTC

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 29, 2026 21:23 Inactive
Comment thread apps/web/lib/developer-list-params.ts Outdated
) {
return {
limit: Math.min(
Math.max(1, Math.trunc(Number(limit)) || DEFAULT_LIMIT),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8a5cbdd: limit=0.5 and limit=-0.5 now return 1 video, and both cases are in the test.

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 29, 2026 22:28 Inactive

This branch was previously deployed

1 inactive deployment
Preview – cap-status — 8a5cbdd1 Deployed Oct 29, 2026 by vercel[bot]
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.

Developer API video list returns 500 for fractional or oversized limit/offset

1 participant