fix(activity): clamp public user pagination params#284
Conversation
Greptile SummaryThis PR tightens pagination input handling in the public user activity route by replacing bare
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to input parsing and introduces no new external dependencies or behavioral changes beyond the intended clamping. Both helpers handle NaN, null, empty string, zero, negative, and oversized values correctly. The No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Route as GET /api/users/:username/activity
participant ParseHelpers as parsePositiveInt / parseNonNegativeInt
participant Supabase
Client->>Route: "GET ?limit=X&offset=Y"
Route->>ParseHelpers: parsePositiveInt(limit, 20)
ParseHelpers-->>Route: clamped limit (1-50, default 20)
Route->>ParseHelpers: parseNonNegativeInt(offset, 0)
ParseHelpers-->>Route: "clamped offset (>=0, default 0)"
Route->>Supabase: profiles.select(id).eq(username).single()
alt profile not found
Supabase-->>Route: data null, error present
Route-->>Client: 404 User not found
else profile found
Supabase-->>Route: data with id
Route->>Supabase: "activities.select(*).eq(user_id).eq(is_public,true).order().range(offset, offset+limit-1)"
alt DB error
Supabase-->>Route: error
Route-->>Client: 400 error message
else success
Supabase-->>Route: data and count
Route-->>Client: 200 data with pagination
end
end
Reviews (1): Last reviewed commit: "test(activity): cover public user pagina..." | Re-trigger Greptile |
Summary
Closes #283
Validation
Submitted for the ugig bounty: I will pay for every bug fix found and PR submitted that fixes it.
Solana wallet for bounty payout:
Dy4yMkjCfupxaURt6iTMUrxqSDEmAJPPkKF66QahxJZD