apache/hadoop · warning · BadRequestException
startedTimeEnd must be greater than 0
Error message
startedTimeEnd must be greater than 0
What it means
Thrown by the JobHistoryServer REST API (HsWebServices.getJobs) when the startedTimeEnd query parameter of GET /ws/v1/history/mapreduce/jobs parses to a negative long. The endpoint validates the epoch-milliseconds window for filtering jobs by start time and rejects negative bounds with a JAX-RS BadRequestException, which surfaces as HTTP 400. Despite the wording, the code only rejects values < 0 (sEnd < 0), so 0 itself is accepted.
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:225
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 {
sEnd = Long.parseLong(startedEnd);
} catch (NumberFormatException e) {
throw new BadRequestException("Invalid number format: " + e.getMessage());
}
if (sEnd < 0) {
throw new BadRequestException("startedTimeEnd must be greater than 0");
}
}
if (sBegin != null && sEnd != null && sBegin > sEnd) {
throw new BadRequestException(
"startedTimeEnd must be greater than startTimeBegin");
}
Long fBegin = null;
if (finishBegin != null && !finishBegin.isEmpty()) {
try {
fBegin = Long.parseLong(finishBegin);
} catch (NumberFormatException e) {
throw new BadRequestException("Invalid number format: " + e.getMessage());
}
if (fBegin < 0) {
throw new BadRequestException("finishedTimeBegin must be greater than 0");
}
}View on GitHub (pinned to 2add963021)
Solutions
- Pass startedTimeEnd as a non-negative epoch-milliseconds value (e.g. System.currentTimeMillis())
- If no end bound is wanted, omit the startedTimeEnd parameter entirely rather than sending -1
- Double-check client-side window math: startedTimeBegin <= startedTimeEnd, both >= 0
Example fix
// before long end = begin - 3600_000; // sign error -> negative curl "http://jhs:19888/ws/v1/history/mapreduce/jobs?startedTimeBegin=$begin&startedTimeEnd=$end" // after long end = begin + 3600_000; // 1h window, non-negative // or omit startedTimeEnd when unbounded
Defensive patterns
Strategy: validation
Validate before calling
long end = ...;
if (end < 0) end = System.currentTimeMillis(); // clamp, or drop param
Map<String,String> q = new LinkedHashMap<>();
if (end >= 0) q.put("startedTimeEnd", Long.toString(end));
// build URL only from sanitized q Prevention
- Treat optional numeric REST params as absent-by-default; never send sentinel values like -1
- Centralize epoch-millis computation in one client helper so sign/window bugs surface once
- Log the exact query string on any 400 to make parameter mistakes obvious
When it happens
Trigger: Calling GET /ws/v1/history/mapreduce/jobs?startedTimeEnd=-1 (or any negative number). The parameter must be absent, empty, or a non-negative epoch-milliseconds long.
Common situations: Computing end = begin - window instead of begin + window when building a time window client-side; Passing a sentinel like -1 to mean 'no bound' instead of omitting the parameter; Clock/sign arithmetic bugs when converting human-readable dates to epoch millis
Related errors
- startedTimeEnd must be greater than startTimeBegin
- finishedTimeBegin must be greater than 0
- finishedTimeEnd must be greater than 0
- finishedTimeEnd must be greater than finishedTimeBegin
- tasktype must be either m or r
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/92c9a207dd2fbc39.
Report an issue: GitHub.