apache/hadoop · warning · BadRequestException

startedTimeBegin must be greater than 0

Error message

startedTimeBegin must be greater than 0

What it means

GET /ws/v1/history/jobs rejects a negative startedTimeBegin with HTTP 400 'startedTimeBegin must be greater than 0'. The code actually rejects only values < 0, so startedTimeBegin=0 is accepted despite the message wording. The parameter is the inclusive lower bound on job start time in epoch milliseconds.

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

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

View on GitHub (pinned to 2add963021)

Solutions

  1. Send 0 or a positive epoch-milliseconds value; 0 is accepted and acts as no effective lower bound.
  2. Fix client time math so the begin value cannot go negative.
  3. Validate parameters before the call.

Example fix

# before
 curl 'http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=-3600000'  # HTTP 400

# after
 curl 'http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=0'
Defensive patterns

Strategy: validation

Validate before calling

const begin = Math.max(0, Date.now() - windowMs); // clamp before sending
const url = `http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=${begin}`;

Type guard

function isValidBegin(v: unknown): v is number {
  return typeof v === 'number' && Number.isInteger(v) && v >= 0;
}

Prevention

When it happens

Trigger: startedTimeBegin=-1 or any negative epoch value; client time-window arithmetic (now - window) underflowing to a negative number.

Common situations: Relative-time math producing negatives; -1 used as an 'unset' sentinel; seconds-vs-milliseconds conversion sign or scale errors.

Related errors


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