Validate browse pagination params#108
Merged
ralyodio merged 1 commit intoJun 17, 2026
Merged
Conversation
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.
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.