Skip to content

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

Merged
richiemcilroy merged 2 commits into
CapSoftware:mainfrom
ghazy2001:fix/developer-api-videos-pagination-bounds-3568
Nov 4, 2026
Merged

richiemcilroy merged 2 commits 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; no actionable issues were found.

Summary

The PR makes developer video pagination return finite, bounded integers before passing values to the database.

  • Developer video lists now bound and round pagination inputs.

Since the previous review, only test formatting changed. No new actionable issues were found.

Reviews (2) · Last reviewed commit: "style(web): format developer-videos-pagi..." · 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 30, 2026 10:15pm UTC

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks! Can you get Greptile to 5/5 on the latest commit? Then we'll take a look.

@ghazy2001

Copy link
Copy Markdown
Contributor Author

@greptileai review

Re-requesting review on latest commit a353afd (formatted with Biome, unit tests passing).

@richiemcilroy
richiemcilroy merged commit e6a5018 into CapSoftware:main Nov 4, 2026
30 of 31 checks passed

This branch was previously deployed

1 inactive deployment
Preview – cap-status — a353afd9 Deployed Oct 30, 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

2 participants