fix(events): clamp page param to >= 1 so junk pagination params don't 500 - #2775
Open
mroderick wants to merge 1 commit into
Open
fix(events): clamp page param to >= 1 so junk pagination params don't 500#2775mroderick wants to merge 1 commit into
mroderick wants to merge 1 commit into
Conversation
mroderick
marked this pull request as ready for review
August 3, 2026 07:28
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.
This PR is about saving maintainer attention by not throwing 500 errors when security scanners try to hit the application.
Problem
Rollbar item codebar-production/709: a security scanner hit
/events/past?page=' OR '1'='1and got aPagy::OptionError: expected :page >= 1; got 0500.(params[:page] || 1).to_iconverts the probe string to0, andPagy::Offset.newrejectspage < 1. The same junk input also 500s via?page=,?page=-3, and?page[]=1(the latter asNoMethodErroronArray#to_i).Fix
EventsController#paginated_eventsis the only manualPagy::Offsetpath in the app — every other paginated endpoint uses the standardpagyhelper, which clamps the page viaPagy::Request#resolve_page([page.to_s.to_i, 1].max). This mirrors that exact clamp:The
.to_salso handles array params (?page[]=1). Junk input now renders page 1 (200) instead of a 500, so no more Rollbar notifications from these probes.Tests
Added request specs covering
page=0, SQL injection probe, empty, negative, array, and valid page params. All green; rubocop clean.