fix(notifications): cap pagination offsets#343
Conversation
Greptile SummaryThis PR guards the notifications pagination endpoint against offset abuse by clamping any parsed offset to
Confidence Score: 5/5Safe to merge — the change is a small, well-tested guard with no side effects on normal offset values. The route change is a single-expression clamp that only affects offsets above 100,000; all existing behaviour for valid inputs is unchanged. The new test file correctly mocks all three Supabase calls (including the previously missing profiles update), and the three regression cases verify the exact boundary values produced by the clamping logic. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GET /api/notifications] --> B{auth?}
B -- no --> C[401 Unauthorized]
B -- yes --> D[fire-and-forget: update profiles last_active_at]
D --> E[parse limit and offset from query params]
E --> F{Number.isFinite parsedOffset?}
F -- no --> G[offset = 0]
F -- yes --> H[offset = clamp to 0..MAX_NOTIFICATION_OFFSET]
G --> I[build Supabase query with range]
H --> I
I --> J{unreadOnly?}
J -- yes --> K[add is read_at null filter]
J -- no --> L[execute query]
K --> L
L --> M{error?}
M -- yes --> N[400 Bad Request]
M -- no --> O[fetch unread count]
O --> P[200 JSON response]
Reviews (2): Last reviewed commit: "test(notifications): mock last-active up..." | Re-trigger Greptile |
|
Addressed the Greptile test-harness note in the latest commit. The notification route does a fire-and-forget |
Summary
MAX_NOTIFICATION_OFFSETguard for notification pagination.range()callFixes #342.
Verification
node.exereturns access denied and npm/pnpm are not available in PATH.