quarkusio/quarkus · error · IllegalArgumentException
Limiting to 0 values is not supported
Error message
Limiting to 0 values is not supported
What it means
PanacheBlockingQueryImpl.limit(int max) rejects max == 0 with IllegalArgumentException because the underlying Hibernate range(0, max-1) call would produce range(0,-1), which is invalid. Limiting a query to zero rows is semantically meaningless in this API, so it fails fast.
Source
Thrown at extensions/data/hibernate/runtime/src/main/java/io/quarkus/data/hibernate/runtime/orm/PanacheBlockingQueryImpl.java:43
final Limits<BlockingDataQuery<Entity>> limitingDelegate = new Limits<BlockingDataQuery<Entity>>() {
@Override
public Limit limit() {
io.quarkus.panache.common.Range range = delegate.range();
// convert 0-based range to 1-based Jakarta Data Limit
return Limit.range(range.getStartIndex() + 1, range.getLastIndex() + 1);
}
@Override
public BlockingDataQuery<Entity> limit(Limit limit) {
// startAt is 1-based in Jakarta Data, convert to 0-based; end is inclusive, hence -1 on size
delegate.range((int) (limit.startAt() - 1), (int) (limit.startAt() + limit.maxResults() - 2));
return PanacheBlockingQueryImpl.this;
}
@Override
public BlockingDataQuery<Entity> limit(int max) {
if (max == 0) {
throw new IllegalArgumentException("Limiting to 0 values is not supported");
}
// end is inclusive, hence -1 on size
delegate.range(0, max - 1);
return PanacheBlockingQueryImpl.this;
}
@Override
public BlockingDataQuery<Entity> limit(long start, int max) {
// end is inclusive, hence -1 on size
delegate.range((int) start, (int) (start + max - 1));
return PanacheBlockingQueryImpl.this;
}
@Override
public BlockingDataQuery<Entity> limitFrom(long start) {
// end is inclusive, hence -1 on size
// default page size of Jakarta Data is 10 (see PageRequest)
delegate.range((int) start, (int) (start + 10 - 1));View on GitHub (pinned to e1c734241f)
Solutions
- Guard the caller: only call limit(max) when max > 0
- Skip pagination entirely (return empty list without querying) when max == 0
- Clamp to a minimum of 1 if a row must be returned: limit(Math.max(1, max))
Example fix
// before
query.limit(pageSize).list();
// after
if (pageSize <= 0) {
return Collections.emptyList();
}
query.limit(pageSize).list(); Defensive patterns
Strategy: validation
Validate before calling
if (max <= 0) {
return Collections.emptyList(); // or throw a domain-level error
}
query.limit(max); Type guard
boolean isValidLimit(Integer max) {
return max != null && max > 0;
} Try / catch
try {
return query.limit(requestedMax).list();
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Limiting to 0")) {
return Collections.emptyList();
}
throw e;
} Prevention
- Always validate page size / limit values from client input before calling limit()
- Treat size=0 in pagination requests as 'no results' at the service layer
- Clamp configured limits to >= 1 at config load time
When it happens
Trigger: Calling query.limit(0) — e.g. computing page size 0, an empty-limit config value, or limit(requestedSize) where requestedSize resolves to 0 (empty page request, size=0 in pagination math).
Common situations: Dynamic pagination where clients send size=0; feature flags or config that zero out limits; code like limit(pageSize) without guarding pageSize.
Related errors
- Limiting to 0 values is not supported
- Limiting to 0 values is not supported
- Page index must be >= 0 :
- Page size must be > 0 :
- Start index must be >= 0:
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/f030ddeea3694550.
Report an issue: GitHub.