apache/hadoop · warning · BadRequestException
limit value must be greater then 0
Error message
limit value must be greater then 0
What it means
The JHS REST API (HsWebServices, GET /ws/v1/history/jobs) validates the count query parameter (the result limit). A value that parses as a long but is <= 0 returns HTTP 400 with 'limit value must be greater then 0' — note the 'then' typo in the source, useful when grepping logs. Non-numeric values fail earlier with a NumberFormatException-based 400.
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsWebServices.java:201
@QueryParam("limit") String count,
@QueryParam("state") String stateQuery,
@QueryParam("queue") String queueQuery,
@QueryParam("startedTimeBegin") String startedBegin,
@QueryParam("startedTimeEnd") String startedEnd,
@QueryParam("finishedTimeBegin") String finishBegin,
@QueryParam("finishedTimeEnd") String finishEnd) {
Long countParam = null;
init();
if (count != null && !count.isEmpty()) {
try {
countParam = Long.parseLong(count);
} catch (NumberFormatException e) {
throw new BadRequestException(e.getMessage());
}
if (countParam <= 0) {
throw new BadRequestException("limit value must be greater then 0");
}
}
Long sBegin = null;
if (startedBegin != null && !startedBegin.isEmpty()) {
try {
sBegin = Long.parseLong(startedBegin);
} catch (NumberFormatException e) {
throw new BadRequestException("Invalid number format: " + e.getMessage());
}
if (sBegin < 0) {
throw new BadRequestException("startedTimeBegin must be greater than 0");
}
}
Long sEnd = null;
if (startedEnd != null && !startedEnd.isEmpty()) {
try {View on GitHub (pinned to 2add963021)
Solutions
- Omit the count parameter entirely when no limit is wanted.
- Send a positive integer (count >= 1).
- Fix client code that forwards 0 or -1 as a 'no limit' sentinel.
Example fix
# before curl 'http://jhs:19888/ws/v1/history/jobs?count=0' # HTTP 400 # after curl 'http://jhs:19888/ws/v1/history/jobs?count=10' # HTTP 200 # or omit the parameter for no limit curl 'http://jhs:19888/ws/v1/history/jobs'
Defensive patterns
Strategy: validation
Validate before calling
function buildJobsUrl(base, { count } = {}) {
const params = new URLSearchParams();
if (count !== undefined && count !== null) {
const n = Number(count);
if (!Number.isInteger(n) || n <= 0) {
throw new RangeError(`count must be a positive integer, got ${count}`);
}
params.set('count', String(n));
}
return `${base}/ws/v1/history/jobs?${params.toString()}`;
} Type guard
function isPositiveInt(v: unknown): v is number {
return typeof v === 'number' && Number.isInteger(v) && v > 0;
} Try / catch
try {
const res = await fetch(url);
} catch { /* network only */ }
if (res.status === 400) { /* fix the count param; do not retry unchanged */ } Prevention
- Omit optional limit parameters rather than sending 0.
- Validate positive-integer params client-side before the request.
- Map 'no limit' configs to parameter absence, not a sentinel 0.
When it happens
Trigger: GET /ws/v1/history/jobs?count=0 or any negative count; a client defaulting an unset limit to 0 instead of omitting the parameter.
Common situations: Client code mapping an optional 'no limit' setting to count=0; pagination math producing 0 for empty result sets; UI wiring bugs.
Related errors
- Invalid number format: {}
- startedTimeBegin must be greater than 0
- Parameter [{0}], invalid value [{1}], value must be [{2}]
- Invalid blacklistDisablePercent: {}. Should be an integer be
- job, {}, is not found
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/843cf34de3af0567.
Report an issue: GitHub.