fix(notifications): clamp invalid pagination ranges - #306
Conversation
Greptile SummaryThis PR fixes a bug where negative or zero
Confidence Score: 5/5The change is narrowly scoped to input sanitisation of two query params and cannot produce worse range arguments than the previous code. Both bounds are correctly applied before the No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GET /api/notifications] --> B[parseInt limit param]
B --> C{isFinite?}
C -- Yes --> D[clamp to 1..100]
C -- No/NaN --> E[default 50]
D --> F[final limit]
E --> F
A --> G[parseInt offset param]
G --> H{isFinite?}
H -- Yes --> I[clamp to min 0]
H -- No/NaN --> J[default 0]
I --> K[final offset]
J --> K
F & K --> L[range offset to offset plus limit minus 1]
L --> M[Supabase query]
M --> N[Return paginated notifications]
Reviews (2): Last reviewed commit: "fix(notifications): parse pagination par..." | Re-trigger Greptile |
Summary
Fixes #297.
Verification
.range(...).