{"record":{"id":"7683c44e65442a62","repo":"apache/hadoop","slug":"finishedtimeend-must-be-greater-than-finishedtimeb","errorCode":null,"errorMessage":"finishedTimeEnd must be greater than finishedTimeBegin","messagePattern":"finishedTimeEnd must be greater than finishedTimeBegin","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":256,"sourceCode":"        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);\n      } catch (NumberFormatException e) {\n        throw new BadRequestException(\"Invalid number format: \" + e.getMessage());\n      }\n      if (fEnd < 0) {\n        throw new BadRequestException(\"finishedTimeEnd must be greater than 0\");\n      }\n    }\n    if (fBegin != null && fEnd != null && fBegin > fEnd) {\n      throw new BadRequestException(\n          \"finishedTimeEnd must be greater than finishedTimeBegin\");\n    }\n    \n    JobState jobState = null;\n    if (stateQuery != null) {\n      jobState = JobState.valueOf(stateQuery);\n    }\n\n    return ctx.getPartialJobs(0l, countParam, userQuery, queueQuery, \n        sBegin, sEnd, fBegin, fEnd, jobState);\n  }\n\n  @GET\n  @Path(\"/mapreduce/jobs/{jobid}\")\n  @Produces({ MediaType.APPLICATION_JSON + \"; \" + JettyUtils.UTF_8,\n      MediaType.APPLICATION_XML + \"; \" + JettyUtils.UTF_8 })\n  public JobInfo getJob(@Context HttpServletRequest hsr,\n      @PathParam(\"jobid\") String jid) {","sourceCodeStart":238,"sourceCodeEnd":274,"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#L238-L274","documentation":"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.","triggerScenarios":"GET /ws/v1/history/mapreduce/jobs?finishedTimeBegin=1700001000000&finishedTimeEnd=1700000000000 — any call where the lower bound exceeds the upper bound.","commonSituations":"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","solutions":["Swap the values so finishedTimeBegin <= finishedTimeEnd","Derive both from one expression: fBegin = t0, fEnd = t0 + duration","Add a client-side assert on window ordering for all four time params"],"exampleFix":"// before\nparams.add(\"finishedTimeBegin\", String.valueOf(t0 + dur));\nparams.add(\"finishedTimeEnd\", String.valueOf(t0));\n\n// after\nparams.add(\"finishedTimeBegin\", String.valueOf(t0));\nparams.add(\"finishedTimeEnd\", String.valueOf(t0 + dur));","handlingStrategy":"validation","validationCode":"void assertWindow(Long begin, Long end, String name) {\n  if (begin != null && end != null && begin > end)\n    throw new IllegalArgumentException(name + \" window inverted: \" + begin + \" > \" + end);\n}\nassertWindow(fBegin, fEnd, \"finishedTime\");\nassertWindow(sBegin, sEnd, \"startedTime\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate all four time params (order + non-negative + numeric) in one place before the request","Derive finished-time window from the job listing you already have instead of guessing clocks","Keep a shared query-param sanitizer for every JHS endpoint you call"],"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"}