Fix /api/bounties pagination defaults - #300
Conversation
Greptile SummaryThis PR tightens the
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to input parsing, the new logic is correct for all edge cases, and the tests validate each one. The guard logic (Number.isFinite && > 0) correctly handles null, empty string, zero, negative, NaN, Infinity, and fractional inputs. The Math.floor normalisation and the 100-cap are applied in the right order. All four new tests assert the exact range() call arguments, which are the direct output of the fixed parsing. No pre-existing code paths are modified. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GET /api/bounties] --> B[Read limit param]
B --> C{isFinite AND > 0?}
C -- No --> D[limitCandidate = 50 default]
C -- Yes --> E[limitCandidate = Math.floor limitRaw]
D --> F[limit = Math.min limitCandidate, 100]
E --> F
F --> G[Read page param]
G --> H{isFinite AND > 0?}
H -- No --> I[page = 1]
H -- Yes --> J[page = Math.floor pageRaw]
I --> K[offset = page-1 × limit]
J --> K
K --> L[supabase .range offset, offset+limit-1]
Reviews (1): Last reviewed commit: "Fix /api/bounties pagination defaults" | Re-trigger Greptile |
Fixes #289.
limitas the existing default (50), while keeping the max cap of 100.pageas page 1.limit=0, negative values, non-numeric input, andlimit>100.Tested:
npm run test:run -- src/app/api/bounties/route.test.ts(installed withnpm install --ignore-scriptsto avoid a missingpnpmpostinstall in this environment).