Skip to content

Clamp zero popular-tags limits instead of expanding to the default #360

@Zekbot001

Description

@Zekbot001

Bug

GET /api/tags/popular currently parses its limit query with:

Math.max(parseInt(searchParams.get(limit) || 50, 10) || 50, 1)

Because 0 || 50 evaluates to 50, requesting /api/tags/popular?limit=0 expands to the default 50 results instead of clamping to the documented minimum bound of 1. The ad hoc parser also partially accepts malformed numeric strings.

Expected

Use the existing shared bounded pagination parser so limit=0 clamps to 1, malformed values fall back to 50, and oversized values cap at 200.

Proposed fix

Replace the local expression with parsePaginationParam(...) and add focused route coverage for zero, malformed, and oversized values.

Paid task context: https://ugig.net/gigs/abd6b2a0-e728-48cf-a46f-f99e419ed94e

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions