Skip to content

Validate breakdown API page param to return 400 instead of 500#6520

Open
SAY-5 wants to merge 1 commit into
plausible:masterfrom
SAY-5:fix-breakdown-page-validation
Open

Validate breakdown API page param to return 400 instead of 500#6520
SAY-5 wants to merge 1 commit into
plausible:masterfrom
SAY-5:fix-breakdown-page-validation

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Changes

The breakdown endpoint read page with String.to_integer(Map.get(params, "page", "1")), which raises ArgumentError on any non-numeric value (page=foo, page=1.5, page=), so the request returned a 500 instead of a client error. It also accepted page=0 and negatives. This adds validate_or_default_page/1 mirroring the existing validate_or_default_limit/1 and moves it into the with chain, so invalid pages now return a 400. Closes #6500.

Tests

  • Automated tests have been added
  • This PR does not require tests

Changelog

  • Entry has been added to changelog
  • This PR does not make a user-facing change

Documentation

  • Docs have been updated
  • This change does not need a documentation update

Dark mode

  • The UI has been tested both in dark and light mode
  • This PR does not change the UI

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stats API breakdown endpoint returns 500 on non-integer page parameter

1 participant