fix(feed): clamp invalid lounge feed page values before Supabase range queries#375
fix(feed): clamp invalid lounge feed page values before Supabase range queries#375Nexu0ps wants to merge 1 commit into
Conversation
Replaces raw `Number(resolvedParams.page) || 1` with the shared parsePageParam helper so negative, non-finite, and huge page values normalize correctly before the Supabase .range() offset is built. Matches the pagination-hardening pattern used on other listing pages. Fixes profullstack#358
Greptile SummaryThis PR fixes invalid page-parameter handling in the lounge feed by replacing the inline
Confidence Score: 5/5Safe to merge — a one-line substitution that tightens input validation with no functional regressions on valid inputs. The swap is mechanical: both the old and new code produce 1 for missing/invalid page values, and the new helper additionally rejects negative numbers and caps extremely large values that could push the Supabase range offset into meaningless territory. The helper is already in use on multiple other routes with identical logic, so its correctness is well-established. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant FeedContent
participant parsePageParam
participant Supabase
Browser->>FeedContent: "GET /feed?page=value"
FeedContent->>parsePageParam: parsePageParam(resolvedParams.page)
Note over parsePageParam: parseInt(value, 10), clamp to [1, 1000], fallback 1 if non-finite
parsePageParam-->>FeedContent: safe page number
FeedContent->>FeedContent: "offset = (page - 1) * limit"
FeedContent->>Supabase: .range(offset, offset + limit - 1)
Supabase-->>FeedContent: posts + count
FeedContent-->>Browser: rendered feed page
Reviews (1): Last reviewed commit: "fix(feed): use parsePageParam to clamp i..." | Re-trigger Greptile |
Fixes #358
Replaces
Number(resolvedParams.page) || 1with the sharedparsePageParamhelper already used by /affiliates, /directory, /for-hire, and /gigs.This ensures negative, non-finite (Infinity/-Infinity), and excessively large page values are normalized before the Supabase
.range()offset is calculated, matching the pagination-hardening pattern applied across the codebase.Tested: pattern matches existing usage on affiliated listing pages.