apache/druid · error · IllegalArgumentException
Limit must be greater than zero!
Error message
Limit must be greater than zero!
What it means
SQLAuditManager.fetchAuditHistory validates the requested limit for how many audit entries to return. If the caller passes a limit less than 1, getLimit throws this IllegalArgumentException immediately. The limit must be a positive integer because it is used as a page/row count in the database query.
Solutions
- Pass a limit >= 1 in the audit history request (e.g. ?limit=25).
- If 'no limit' is intended, omit the limit parameter if the API supports a null/default, or pass a large value like 10000.
- Fix client code that defaults a missing query parameter to 0; default to a positive constant instead.
Example fix
// before
String limitParam = req.getParameter("limit");
int limit = limitParam == null ? 0 : Integer.parseInt(limitParam);
auditManager.fetchAuditHistory(type, interval, limit);
// after
int limit = limitParam == null ? 25 : Math.max(1, Integer.parseInt(limitParam));
auditManager.fetchAuditHistory(type, interval, limit); Defensive patterns
Strategy: validation
Validate before calling
if (!Number.isInteger(limit) || limit < 1) {
throw new RangeError(`limit must be a positive integer, got ${limit}`);
}
auditManager.fetchAuditHistory(type, interval, limit); Type guard
function isValidLimit(limit) {
return Number.isInteger(limit) && limit >= 1;
} Try / catch
try {
entries = auditManager.fetchAuditHistory(type, interval, limit);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Limit must be greater than zero")) {
entries = auditManager.fetchAuditHistory(type, interval, 25);
} else { throw e; }
} Prevention
- Never use 0 to mean 'unlimited' with Druid audit APIs; omit or use a large positive value.
- Clamp client-supplied limits with Math.max(1, limit) before sending requests.
When it happens
Trigger: Calling fetchAuditHistory(type, interval, limit) with limit == 0 or any negative number, e.g. a client query string like ?limit=0 or a deserialized/default limit of 0.
Common situations: API clients passing 0 to mean 'unlimited' (this API does not support that convention); frontend code defaulting a missing limit parameter to 0 instead of a positive value; automated scripts constructing the request with an unset variable.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Cluster-level rules cannot be empty.
- given update for lookup
- A local input source accepts only one of
- A local input source can set parameter
- A local input source requires one parameter of
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/dd02161bc94a5dcf.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/main/java/org/apache/druid/server/audit/SQLAuditManager.java:197
.map(resultMapper)
.list()
);
}
private Interval createAuditHistoryIntervalIfNull(Interval interval)
{
if (interval == null) {
DateTime now = DateTimes.nowUtc();
return new Interval(now.minus(config.getAuditHistoryMillis()), now);
} else {
return interval;
}
}
private int getLimit(int limit) throws IllegalArgumentException
{
if (limit < 1) {
throw new IllegalArgumentException("Limit must be greater than zero!");
}
return limit;
}
@Override
public List<AuditEntry> fetchAuditHistory(final String type, Interval interval)
{
final Interval theInterval = createAuditHistoryIntervalIfNull(interval);
return dbi.withHandle(
(Handle handle) -> handle
.createQuery(
StringUtils.format(
"SELECT payload FROM %s WHERE type = :type and created_date between :start_date and "
+ ":end_date ORDER BY created_date",
getAuditTable()
)
)
.bind("type", type)View on GitHub (pinned to 9b90983fd2)