Skip to content

Clamp page size to a minimum of one - #72

Merged
mmalfertheiner merged 1 commit into
mainfrom
clamp-page-size-to-a-minimum-of-one
Aug 27, 2026
Merged

Clamp page size to a minimum of one#72
mmalfertheiner merged 1 commit into
mainfrom
clamp-page-size-to-a-minimum-of-one

Conversation

@mmalfertheiner

Copy link
Copy Markdown
Member

Problem

PageParameter clamps the page to 0 and the size to MAX_PAGE_SIZE, but a size below 1 passes through unchanged. toPageRequest() then calls PageRequest.of, which throws IllegalArgumentException for a size below one. In consuming applications a request with size=0 or a negative size ends in an unhandled exception (HTTP 500) instead of a corrected page request.

Fix

The size is now clamped to a minimum of 1, with a warn log in the same style as the existing maximum clamp. This matches how the page is already clamped to 0.

Tests

New PageParameterTest covers the defaults for null values, the page clamp, both size clamps (minimum and maximum), and that toPageRequest() succeeds for a zero size.

🤖 Generated with Claude Code

PageParameter clamped the page to 0 and the size to MAX_PAGE_SIZE, but
a size below 1 passed through unchanged. toPageRequest then called
PageRequest.of, which throws IllegalArgumentException for a size below
one. In consuming applications a request with size=0 ended in an
unhandled exception instead of a corrected page request.

The size is now clamped to a minimum of 1, with a warn log in the same
style as the existing maximum clamp.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@SirCotare SirCotare left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mmalfertheiner
mmalfertheiner merged commit 27b9940 into main Aug 27, 2026
1 check passed
@mmalfertheiner
mmalfertheiner deleted the clamp-page-size-to-a-minimum-of-one branch August 27, 2026 15:13
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.

2 participants