apache/hadoop · warning · BadRequestException

finishedTimeEnd must be greater than finishedTimeBegin

Error message

finishedTimeEnd must be greater than finishedTimeBegin

What it means

Thrown by the JobHistoryServer REST API (HsWebServices.getJobs) when both finishedTimeBegin and finishedTimeEnd are supplied and finishedTimeBegin > finishedTimeEnd. The finished-time filter window must be ordered (equality allowed); otherwise the request fails with HTTP 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:256

        throw new BadRequestException("Invalid number format: " + e.getMessage());
      }
      if (fBegin < 0) {
        throw new BadRequestException("finishedTimeBegin must be greater than 0");
      }
    }
    Long fEnd = null;
    if (finishEnd != null && !finishEnd.isEmpty()) {
      try {
        fEnd = Long.parseLong(finishEnd);
      } catch (NumberFormatException e) {
        throw new BadRequestException("Invalid number format: " + e.getMessage());
      }
      if (fEnd < 0) {
        throw new BadRequestException("finishedTimeEnd must be greater than 0");
      }
    }
    if (fBegin != null && fEnd != null && fBegin > fEnd) {
      throw new BadRequestException(
          "finishedTimeEnd must be greater than finishedTimeBegin");
    }
    
    JobState jobState = null;
    if (stateQuery != null) {
      jobState = JobState.valueOf(stateQuery);
    }

    return ctx.getPartialJobs(0l, countParam, userQuery, queueQuery, 
        sBegin, sEnd, fBegin, fEnd, jobState);
  }

  @GET
  @Path("/mapreduce/jobs/{jobid}")
  @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
      MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
  public JobInfo getJob(@Context HttpServletRequest hsr,
      @PathParam("jobid") String jid) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Swap the values so finishedTimeBegin <= finishedTimeEnd
  2. Derive both from one expression: fBegin = t0, fEnd = t0 + duration
  3. Add a client-side assert on window ordering for all four time params

Example fix

// before
params.add("finishedTimeBegin", String.valueOf(t0 + dur));
params.add("finishedTimeEnd", String.valueOf(t0));

// after
params.add("finishedTimeBegin", String.valueOf(t0));
params.add("finishedTimeEnd", String.valueOf(t0 + dur));
Defensive patterns

Strategy: validation

Validate before calling

void assertWindow(Long begin, Long end, String name) {
  if (begin != null && end != null && begin > end)
    throw new IllegalArgumentException(name + " window inverted: " + begin + " > " + end);
}
assertWindow(fBegin, fEnd, "finishedTime");
assertWindow(sBegin, sEnd, "startedTime");

Prevention

When it happens

Trigger: GET /ws/v1/history/mapreduce/jobs?finishedTimeBegin=1700001000000&finishedTimeEnd=1700000000000 — any call where the lower bound exceeds the upper bound.

Common situations: Begin/end swapped in the query-string builder; Window computed against different time bases (job finish time is server-side; client clock may differ); Refactoring that reused the started-time variables for the finished-time parameters

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/7683c44e65442a62. Report an issue: GitHub.