Skip to content

fix(web): validate and bound developer api video list pagination (#3568) - #3576

Open
ghazy2001 wants to merge 1 commit into
CapSoftware:mainfrom
ghazy2001:fix/developer-api-videos-pagination-bounds-3568
Open

ghazy2001 wants to merge 1 commit into
CapSoftware:mainfrom
ghazy2001:fix/developer-api-videos-pagination-bounds-3568

Conversation

@ghazy2001

@ghazy2001 ghazy2001 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3568
Linear: CAP-958

GET /api/developer/v1/videos returned 500 Internal Server Error when limit or offset were passed fractional numbers (e.g. limit=5.5, offset=2.5) or oversized integers due to MySQL syntax errors in LIMIT and OFFSET.

Root Cause

apps/web/app/api/developer/v1/[...route]/videos.ts passed Number(c.req.query("limit")) and Number(c.req.query("offset")) directly into Drizzle's .limit(...) and .offset(...) without integer rounding or offset upper bounds.

Changes

  • Created apps/web/lib/developer-pagination.ts providing parseDeveloperVideosPagination:
    • Enforces integers by flooring valid finite numbers (Math.floor).
    • Bounds limit between 1 and 100 with default 50 (DEFAULT_DEVELOPER_API_LIMIT, MAX_DEVELOPER_API_LIMIT).
    • Bounds offset between 0 and 1,000,000,000 (MAX_DEVELOPER_API_OFFSET) with default 0.
    • Safely falls back to defaults for invalid, negative, or non-numeric inputs.
  • Integrated parseDeveloperVideosPagination in videos.ts.
  • Added unit tests in apps/web/__tests__/unit/developer-videos-pagination.test.ts covering missing/empty params, valid integers, fractional flooring, non-numeric fallbacks, and oversized bounds.

Test plan

  • Ran unit tests with Bun:
    • 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)
  • Verified limit=5.5 floors to 5, offset=2.5 floors to 2, and oversized offset is bounded cleanly, preventing MySQL 500 errors.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

The PR prevents invalid pagination values from reaching the developer video query.

  • Developer video lists use whole-number pagination within fixed bounds.

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

…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
@vercel
vercel Bot temporarily deployed to Preview – cap-status October 29, 2026 22:32 Inactive
@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:32pm UTC

This branch was previously deployed

1 inactive deployment
Preview – cap-status — 291adc42 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