fix(zaps): clamp history pagination params - #294
Conversation
Greptile SummaryThis PR hardens the zap history pagination endpoint by replacing raw
Confidence Score: 5/5Safe to merge — the changes are narrowly scoped to input validation and a one-line count fix, with new tests that verify each adjusted code path. The logic changes are small and well-tested: the helper functions correctly handle all edge cases (null, empty string, zero, negative, float-like strings), the clamping math is verified by the test assertions, and the count propagation fix is directly exercised by the empty-result test case. No pre-existing behavior is altered beyond the targeted bug fixes. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GET /api/zaps/history] --> B{Auth?}
B -- No --> C[401 Unauthorized]
B -- Yes --> D["Parse limit via parsePositiveInt (default=50, cap=100)"]
D --> E["Parse offset via parseNonNegativeInt (default=0)"]
E --> F["Supabase: SELECT zaps with count=exact, range(offset..offset+limit-1)"]
F --> G{"zaps null or empty?"}
G -- Yes --> H["Return {zaps:[], total: count || 0} — skip profile lookup"]
G -- No --> I["Collect unique sender/recipient IDs"]
I --> J["Supabase: SELECT profiles IN ids"]
J --> K["Enrich zaps with profile info"]
K --> L["Return {zaps: enriched, total: count || 0}"]
Reviews (3): Last reviewed commit: "chore(zaps): normalize history route dif..." | Re-trigger Greptile |
|
Submitted this PR for the ugig bug-fix/testing gig.\n\nThe PR is ready for review:\n- fixes #293\n- local route test passes\n- Socket checks are passing\n\nSolana wallet for bounty payout:\nDy4yMkjCfupxaURt6iTMUrxqSDEmAJPPkKF66QahxJZD |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
Follow-up completed after review feedback:
|
Summary
limitandoffsetbefore building the Supabase rangelimitto 50 and cap large limits at 100offsetto 0Fixes #293
Payment
Test plan
corepack pnpm test -- src/app/api/zaps/history/route.test.ts