apache/hadoop · warning · BadRequestException

finishedTimeBegin must be greater than 0

Error message

finishedTimeBegin must be greater than 0

What it means

Thrown by the JobHistoryServer REST API (HsWebServices.getJobs) when the finishedTimeBegin query parameter parses to a negative long. Like the started-time bounds, the finished-time window filter only accepts non-negative epoch-milliseconds values; a negative lower bound is rejected with HTTP 400. The message says 'greater than 0' but the check is fBegin < 0, so 0 is actually permitted.

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

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

View on GitHub (pinned to 2add963021)

Solutions

  1. Send a non-negative epoch-milliseconds value computed as now - windowLength
  2. Omit finishedTimeBegin entirely when you do not want a lower bound
  3. Initialize optional numeric params to null/absent, never -1

Example fix

// before
long fBegin = -3600_000; // meant 'last hour'

// after
long fBegin = System.currentTimeMillis() - 3600_000;
// or omit the parameter when unbounded
Defensive patterns

Strategy: validation

Validate before calling

Long fBegin = Optional.ofNullable(cfg.get("finishedTimeBegin"))
    .map(String::trim).filter(s -> !s.isEmpty()).map(Long::parseLong)
    .filter(v -> v >= 0).orElse(null); // null = omit param

Prevention

When it happens

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

Common situations: Using a negative offset to express 'last hour' instead of computing now - 3600000; Defaulting unset numeric fields to -1 in the client and always sending them; Sign errors when subtracting a duration from a base timestamp

Related errors


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