{"record":{"id":"7707715223f7005e","repo":"apache/hadoop","slug":"finishedtimeend-must-be-greater-than-0","errorCode":null,"errorMessage":"finishedTimeEnd must be greater than 0","messagePattern":"finishedTimeEnd must be greater than 0","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":252,"sourceCode":"    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);\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}\")","sourceCodeStart":234,"sourceCodeEnd":270,"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#L234-L270","documentation":"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).","triggerScenarios":"GET /ws/v1/history/mapreduce/jobs?finishedTimeEnd=-1 — any negative integer supplied for this parameter.","commonSituations":"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'","solutions":["Omit finishedTimeEnd when no upper bound is needed","Compute end = min(now, desired ceiling) and clamp to >= 0 before sending","Audit shared HTTP client code for sentinel-value defaults"],"exampleFix":"// before\nurl += \"&finishedTimeEnd=\" + (-1);\n\n// after\n// just omit the parameter, or:\nurl += \"&finishedTimeEnd=\" + System.currentTimeMillis();","handlingStrategy":"validation","validationCode":"long fEnd = Math.max(0, desiredEnd); // clamp before sending\nif (fEnd <= 0 && desiredEnd < 0) { /* omit the parameter instead */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp all computed bounds to >= 0 at the edge of your HTTP layer","Document that JHS bounds are inclusive epoch millis and 0 is legal","Never reuse '-1 means unbounded' conventions from other APIs"],"tags":["hadoop","mapreduce","jobhistory","rest","http-400","query-param","time-range"],"backgroundTag":"query-param-validation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}