Skip to content

Validate browse pagination params#108

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
phucnguyen1707:fix-browse-pagination
Jun 17, 2026
Merged

Validate browse pagination params#108
ralyodio merged 1 commit into
profullstack:masterfrom
phucnguyen1707:fix-browse-pagination

Conversation

@phucnguyen1707

Copy link
Copy Markdown
Contributor

Fixes #107.\n\nThis tightens GET /api/browse pagination parsing so Supabase range bounds stay safe. Previously limit and offset used parseInt, so malformed, negative, fractional, or unsafe integer values could produce NaN, negative bounds, or silent truncation before .range().\n\nThe route now validates pagination with a bounded integer parser:\n- invalid limit values fall back to 50\n- valid limit values are capped at the documented max of 100\n- invalid offset values fall back to 0\n- offset remains unbounded above by design, since deep pages simply return empty result sets\n\nValidation:\n- pnpm test src/app/api/browse/pagination.test.ts\n- pnpm exec tsc --noEmit --pretty false\n- pnpm exec eslint src/app/api/browse/route.ts src/app/api/browse/pagination.test.ts\n- git diff --check\n- pre-commit full vitest suite: 150 files, 2245 passed, 3 skipped\n\nNote: local Node is v22.22.2 while package.json requests >=24.0.0, but targeted checks and the full pre-commit suite passed.

@ralyodio
ralyodio merged commit edffece into profullstack:master Jun 17, 2026
8 checks passed
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.

GET /api/browse accepts invalid pagination params

2 participants