The GET /api/notifications endpoint parses offset without clamping it to a non-negative value.
Repro
GET /api/notifications?offset=-10
Observed:
const offset = Number(searchParams.get("offset")) || 0 — Number("-10") is -10 which is truthy, so the || 0 fallback is skipped
offset = -10 is passed to .range(-10, limit - 11), causing a Supabase database error (500)
Fix
Clamp offset to a minimum of 0:
const offset = Math.max(0, Number(searchParams.get("offset")) || 0);
The
GET /api/notificationsendpoint parsesoffsetwithout clamping it to a non-negative value.Repro
Observed:
const offset = Number(searchParams.get("offset")) || 0—Number("-10")is-10which is truthy, so the|| 0fallback is skippedoffset = -10is passed to.range(-10, limit - 11), causing a Supabase database error (500)Fix
Clamp offset to a minimum of
0: