quarkusio/quarkus · error · IllegalArgumentException
Page size must be > 0 :
Error message
Page size must be > 0 :
What it means
Panache's Page constructor requires a strictly positive page size; a zero or negative size cannot describe a page of results, so the constructor throws IllegalArgumentException with the offending value.
Source
Thrown at extensions/panache/panache-common/runtime/src/main/java/io/quarkus/panache/common/Page.java:55
*/
public Page(int size) {
this(0, size);
}
/**
* Builds a page of the given index and size.
*
* @param index the page index (0-based)
* @param size the page size
* @throws IllegalArgumentException if the page index is less than 0
* @throws IllegalArgumentException if the page size is less than or equal to 0
* @see #of(int, int)
*/
public Page(int index, int size) {
if (index < 0)
throw new IllegalArgumentException("Page index must be >= 0 : " + index);
if (size <= 0)
throw new IllegalArgumentException("Page size must be > 0 : " + size);
this.index = index;
this.size = size;
}
/**
* Builds a page of the given index and size.
*
* @param index the page index (0-based)
* @param size the page size
* @throws IllegalArgumentException if the page index is less than 0
* @throws IllegalArgumentException if the page size is less than or equal to 0
*/
public static Page of(int index, int size) {
return new Page(index, size);
}
/**
* Builds a page of the given size.View on GitHub (pinned to e1c734241f)
Solutions
- Validate/clamp the size before constructing: Math.max(1, pageSize).
- Treat size<=0 from clients as an HTTP 400 Bad Request.
- Apply a server-side default page size when the client value is absent or non-positive.
Example fix
// before Page p = Page.of(0, config.pageSize()); // config.pageSize() == 0 // after Page p = Page.of(0, Math.max(1, config.pageSize()));
Defensive patterns
Strategy: validation
Validate before calling
int sz = /* user input */;
if (sz <= 0) throw new BadRequestException("page size must be > 0");
Page p = Page.of(index, sz); Type guard
Page safePage(int index, Integer size) {
return Page.of(index, size == null ? DEFAULT_SIZE : Math.max(1, size));
} Try / catch
try {
Page p = Page.of(index, size);
} catch (IllegalArgumentException e) {
throw new BadRequestException("Invalid page size: " + e.getMessage());
} Prevention
- Clamp page size to at least 1 before constructing Page
- Apply server-side default size when client value is 0/negative
- Validate size in DTO/param binding
When it happens
Trigger: Calling new Page(0, 0), Page.of(0, -10), or building a page from an unvalidated user-provided/zero-defaulted size parameter.
Common situations: Client sends ?size=0; a config default of 0 for page size; integer parsing failures defaulting to 0; division-based size computation producing 0.
Related errors
- Limiting to 0 values is not supported
- Limiting to 0 values is not supported
- Limiting to 0 values is not supported
- Page index must be >= 0 :
- Start index must be >= 0:
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/49652accef1ba39e.
Report an issue: GitHub.