{"record":{"id":"ac2a7dcfc7ddf5ee","repo":"apache/hadoop","slug":"startedtimebegin-must-be-greater-than-0","errorCode":null,"errorMessage":"startedTimeBegin must be greater than 0","messagePattern":"startedTimeBegin 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":213,"sourceCode":"      try {\n        countParam = Long.parseLong(count);\n      } catch (NumberFormatException e) {\n        throw new BadRequestException(e.getMessage());\n      }\n      if (countParam <= 0) {\n        throw new BadRequestException(\"limit value must be greater then 0\");\n      }\n    }\n\n    Long sBegin = null;\n    if (startedBegin != null && !startedBegin.isEmpty()) {\n      try {\n        sBegin = Long.parseLong(startedBegin);\n      } catch (NumberFormatException e) {\n        throw new BadRequestException(\"Invalid number format: \" + e.getMessage());\n      }\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    }","sourceCodeStart":195,"sourceCodeEnd":231,"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#L195-L231","documentation":"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.","triggerScenarios":"startedTimeBegin=-1 or any negative epoch value; client time-window arithmetic (now - window) underflowing to a negative number.","commonSituations":"Relative-time math producing negatives; -1 used as an 'unset' sentinel; seconds-vs-milliseconds conversion sign or scale errors.","solutions":["Send 0 or a positive epoch-milliseconds value; 0 is accepted and acts as no effective lower bound.","Fix client time math so the begin value cannot go negative.","Validate parameters before the call."],"exampleFix":"# before\n curl 'http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=-3600000'  # HTTP 400\n\n# after\n curl 'http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=0'","handlingStrategy":"validation","validationCode":"const begin = Math.max(0, Date.now() - windowMs); // clamp before sending\nconst url = `http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=${begin}`;","typeGuard":"function isValidBegin(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 0;\n}","tryCatchPattern":null,"preventionTips":["Clamp lower-bound timestamps to 0 in client code.","Use 0 instead of -1 as the 'no bound' sentinel.","Watch for seconds/milliseconds scale mistakes in window math."],"tags":["mapreduce","job-history-server","rest","query-params","validation"],"backgroundTag":"invalid-query-parameter","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}