fix(tags): clamp zero and invalid popular-tags limit with parsePaginationParam#377
Open
Nexu0ps wants to merge 1 commit into
Open
fix(tags): clamp zero and invalid popular-tags limit with parsePaginationParam#377Nexu0ps wants to merge 1 commit into
Nexu0ps wants to merge 1 commit into
Conversation
Replaces ad-hoc Math.min/Math.max/parseInt with parsePaginationParam so limit=0 clamps to 1, malformed values fall back to 50, and oversized values cap at 200. Fixes profullstack#360
Greptile SummaryThis PR refactors the
Confidence Score: 5/5Safe to merge — the change is a one-line substitution with a well-tested shared helper and no logic is altered. The only touched line swaps an inline clamping expression for parsePaginationParam, which has its own test file and produces identical or stricter output. The rest of the route is unchanged. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Route as GET /api/tags/popular
participant parsePaginationParam
participant Supabase
Client->>Route: "GET /api/tags/popular?limit=<value>"
Route->>parsePaginationParam: parsePaginationParam(value, 50, 1, 200)
parsePaginationParam-->>Route: clamped limit (1-200, default 50)
Route->>Supabase: "SELECT skills_required FROM gigs WHERE status='active'"
Supabase-->>Route: gigs[]
Route->>Supabase: SELECT tag FROM tag_follows
Supabase-->>Route: follows[]
Route->>Route: build tag counts, sort, slice(0, limit)
Route-->>Client: "{ tags: [...] }"
Reviews (1): Last reviewed commit: "fix(tags): use parsePaginationParam to c..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #360
Replaces the ad-hoc
Math.min(Math.max(parseInt(...) || 50, 1), 200)with the sharedparsePaginationParamhelper solimit=0clamps to1, malformed values fall back to50, and oversized values cap at200.