apache/hadoop · warning · BadRequestException

finishedTimeEnd must be greater than 0

Error message

finishedTimeEnd must be greater than 0

What it means

Thrown by the JobHistoryServer REST API (HsWebServices.getJobs) when the finishedTimeEnd query parameter parses to a negative long. The finished-time window upper bound must be a non-negative epoch-milliseconds value; anything negative is rejected with HTTP 400 (the guard is fEnd < 0, so 0 passes).

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:252

    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");
      }
    }
    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}")

View on GitHub (pinned to 2add963021)

Solutions

  1. Omit finishedTimeEnd when no upper bound is needed
  2. Compute end = min(now, desired ceiling) and clamp to >= 0 before sending
  3. Audit shared HTTP client code for sentinel-value defaults

Example fix

// before
url += "&finishedTimeEnd=" + (-1);

// after
// just omit the parameter, or:
url += "&finishedTimeEnd=" + System.currentTimeMillis();
Defensive patterns

Strategy: validation

Validate before calling

long fEnd = Math.max(0, desiredEnd); // clamp before sending
if (fEnd <= 0 && desiredEnd < 0) { /* omit the parameter instead */ }

Prevention

When it happens

Trigger: GET /ws/v1/history/mapreduce/jobs?finishedTimeEnd=-1 — any negative integer supplied for this parameter.

Common situations: Placeholder/-1 defaults being sent for optional filters; Subtraction order flipped when deriving end from begin (begin - duration instead of begin + duration); Reusing query strings from other APIs where negative timestamps mean 'open'

Related errors


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