{"record":{"id":"18843919e4c73d80","repo":"apache/hadoop","slug":"startedtimeend-must-be-greater-than-starttimebegin","errorCode":null,"errorMessage":"startedTimeEnd must be greater than startTimeBegin","messagePattern":"startedTimeEnd must be greater than startTimeBegin","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsWebServices.java","lineNumber":229,"sourceCode":"      }\n      if (sBegin < 0) {\n        throw new BadRequestException(\"startedTimeBegin must be greater than 0\");\n      }\n    }\n    \n    Long sEnd = null;\n    if (startedEnd != null && !startedEnd.isEmpty()) {\n      try {\n        sEnd = Long.parseLong(startedEnd);\n      } catch (NumberFormatException e) {\n        throw new BadRequestException(\"Invalid number format: \" + e.getMessage());\n      }\n      if (sEnd < 0) {\n        throw new BadRequestException(\"startedTimeEnd must be greater than 0\");\n      }\n    }\n    if (sBegin != null && sEnd != null && sBegin > sEnd) {\n      throw new BadRequestException(\n          \"startedTimeEnd must be greater than startTimeBegin\");\n    }\n\n    Long fBegin = null;\n    if (finishBegin != null && !finishBegin.isEmpty()) {\n      try {\n        fBegin = Long.parseLong(finishBegin);\n      } catch (NumberFormatException e) {\n        throw new BadRequestException(\"Invalid number format: \" + e.getMessage());\n      }\n      if (fBegin < 0) {\n        throw new BadRequestException(\"finishedTimeBegin must be greater than 0\");\n      }\n    }\n    Long fEnd = null;\n    if (finishEnd != null && !finishEnd.isEmpty()) {\n      try {\n        fEnd = Long.parseLong(finishEnd);","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsWebServices.java#L211-L247","documentation":"Thrown by the JobHistoryServer REST API (HsWebServices.getJobs) when both startedTimeBegin and startedTimeEnd are supplied and startedTimeBegin > startedTimeEnd. The window filter requires the start-time range to be well ordered; otherwise the request fails with HTTP 400. Note the message contains a historical typo ('startTimeBegin' vs the actual parameter 'startedTimeBegin') — search for the parameter names, not the message, in docs.","triggerScenarios":"GET /ws/v1/history/mapreduce/jobs?startedTimeBegin=1700000000000&startedTimeEnd=1699999999000 — any call where the begin value is strictly greater than the end value (equality is allowed).","commonSituations":"Swapped begin/end arguments when building the URL; Client computes end relative to a different clock source (local vs server) producing an inverted window; Copy-paste from an example with dates in the wrong order","solutions":["Swap the two values so startedTimeBegin <= startedTimeEnd","Regenerate both bounds from the same instant: begin = now - window, end = now","Validate the ordering in your client before issuing the request"],"exampleFix":"// before\nString url = base + \"?startedTimeBegin=\" + end + \"&startedTimeEnd=\" + begin;\n\n// after\nString url = base + \"?startedTimeBegin=\" + begin + \"&startedTimeEnd=\" + end;\nassert begin <= end;","handlingStrategy":"validation","validationCode":"if (begin != null && end != null && begin > end) {\n  long t = begin; begin = end; end = t; // or reject with a clear client-side error\n}","typeGuard":null,"tryCatchPattern":"// if calling via a generic HTTP client\ntry { resp = get(url); }\ncatch (BadRequestException e) {\n  if (e.getMessage().contains(\"startedTimeEnd must be greater\"))\n    throw new IllegalArgumentException(\"inverted started-time window\", e);\n}","preventionTips":["Assert begin <= end for every time-window pair before building the URL","Generate both bounds from one base instant (now-window, now)","Remember equality is allowed; only strict inversion fails"],"tags":["hadoop","mapreduce","jobhistory","rest","http-400","query-param","time-range"],"backgroundTag":"time-range-validation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}