Validate page param in Stats API breakdown endpoint#6501
Open
nafey7 wants to merge 1 commit into
Open
Conversation
The public Stats API `/api/v1/stats/breakdown` endpoint passed the `page` query parameter directly into `String.to_integer/1`, which raises `ArgumentError` on any non-numeric input, resulting in a 500 Internal Server Error. This mirrors the validation already applied to the sibling `limit` parameter: invalid values now return a clean 400 response with a helpful message instead of crashing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ukutaht
approved these changes
Jul 13, 2026
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.
Changes
The public Stats API
GET /api/v1/stats/breakdownendpoint passed thepagequery parameter straight intoString.to_integer/1, which raisesArgumentErroron any non-numeric input — resulting in a 500 Internal Server Error.This PR validates
pagethe same way the siblinglimitparameter is already validated (validate_or_default_limit/1): invalid or non-positive values now return a clean 400 with a descriptive message.Tests
Added tests to
breakdown_test.exscovering non-integer, negative, and zeropagevalues (mirroring the existinglimitvalidation tests).Notes
pagevalues (including the default of1when omitted) is unchanged.Fixes #6500