apache/druid · warning · IllegalArgumentException
Limit must be greater than zero if set
Error message
Limit must be greater than zero if set
What it means
SQLMetadataSupervisorManager.getAllForId() returns the versioned history of supervisor specs for a given id. It validates the optional limit parameter and throws IllegalArgumentException when a limit is provided that is zero or negative, since a non-positive page size is meaningless for a query row limit.
Solutions
- Omit the limit parameter (pass null) when you want all versions instead of passing 0.
- Clamp the caller-supplied limit to a positive value before calling getAllForId.
- Fix the REST/UI layer to validate that limit > 0 before forwarding it.
Example fix
// before supervisorManager.getAllForId(id, limit); // limit may be 0 or negative // after Integer safeLimit = (limit == null || limit <= 0) ? null : limit; supervisorManager.getAllForId(id, safeLimit);
Defensive patterns
Strategy: validation
Validate before calling
if (limit != null && limit <= 0) {
limit = null; // treat as unlimited
} Type guard
Integer positiveOrNull(Integer limit) { return (limit != null && limit > 0) ? limit : null; } Try / catch
try {
supervisorManager.getAllForId(id, limit);
} catch (IllegalArgumentException e) {
log.warn("Invalid limit supplied: %s", e.getMessage());
} Prevention
- Validate limit query parameters server-side before calling the manager
- Use 'omit for unlimited' semantics in API clients, not limit=0
- Guard pagination math against page=0 producing non-positive limits
When it happens
Trigger: Calling getAllForId(id, 0) or getAllForId(id, -n); REST endpoints that forward an unvalidated limit query parameter straight through (e.g. ?limit=0).
Common situations: UI pagination code computing limit as (page-1)*size with page=0; API clients treating limit=0 as 'unlimited' when the API requires omitting the parameter for unlimited.
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
Related errors
- SeekableStreamSupervisorIOConfig does not support both…
- A local input source accepts only one of
- A local input source can set parameter
- A local input source requires one parameter of
- A local input source requires one property of
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/b2b4bd4a62611757.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/main/java/org/apache/druid/metadata/SQLMetadataSupervisorManager.java:144
try {
String specId = pair.lhs;
retVal.computeIfAbsent(specId, sId -> new ArrayList<>()).add(pair.rhs);
return retVal;
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
)
)
);
}
@Override
public List<VersionedSupervisorSpec> getAllForId(String id, @Nullable Integer limit) throws IllegalArgumentException
{
if (limit != null && limit <= 0) {
throw new IllegalArgumentException("Limit must be greater than zero if set");
}
return ImmutableList.copyOf(
dbi.withHandle(
(HandleCallback<List<VersionedSupervisorSpec>>) handle -> {
String query = StringUtils.format(
"SELECT id, spec_id, created_date, payload FROM %1$s WHERE spec_id = :spec_id ORDER BY id DESC",
getSupervisorsTable()
);
if (limit != null) {
query += " " + connector.limitClause(limit);
}
return handle.createQuery(query)
.bind("spec_id", id)
.map((index, r, ctx) -> createVersionSupervisorSpecFromResponse(r))
.list();View on GitHub (pinned to 9b90983fd2)