{"record":{"id":"3c0ce32472dc8f3b","repo":"apache/hadoop","slug":"invalid-number-format","errorCode":null,"errorMessage":"Invalid number format: {}","messagePattern":"Invalid number format: (.+?)","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":210,"sourceCode":"    init();\n    \n    if (count != null && !count.isEmpty()) {\n      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) {","sourceCodeStart":192,"sourceCodeEnd":228,"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#L192-L228","documentation":"Parsing the startedTimeBegin query parameter of GET /ws/v1/history/jobs with Long.parseLong throwing NumberFormatException yields HTTP 400 'Invalid number format: <detail>', where the detail is the parse error text such as 'For input string: ...'. startedTimeBegin is an epoch-milliseconds lower bound on job start time and must be a plain integer.","triggerScenarios":"startedTimeBegin=2024-01-01 (date string instead of epoch millis); decimal, localized, or scientific-notation values; values with units or stray characters.","commonSituations":"Clients passing ISO dates or formatted timestamps; locale-specific number formatting; values copied from UI time pickers.","solutions":["Convert the timestamp to epoch milliseconds before sending (date +%s000 in shell, Date.now() in JS).","Send a plain integer with no separators or units.","Validate and normalize the parameter client-side before issuing the request."],"exampleFix":"# before\n curl 'http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=2024-01-01'  # HTTP 400\n\n# after\n curl \"http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=$(date -d '2024-01-01' +%s000)\"","handlingStrategy":"validation","validationCode":"function toEpochMillis(v: string | number | Date): string {\n  const n = v instanceof Date ? v.getTime()\n    : typeof v === 'number' ? v\n    : /^\\d+$/.test(v) ? Number(v)\n    : NaN;\n  if (!Number.isInteger(n) || n < 0) {\n    throw new TypeError(`not epoch millis: ${String(v)}`);\n  }\n  return String(n);\n}\nconst url = `http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=${toEpochMillis(begin)}`;","typeGuard":"function isEpochMillis(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 0;\n}","tryCatchPattern":null,"preventionTips":["Convert dates to epoch milliseconds at the client boundary.","Reject formatted date strings before building the URL.","Unit-test time-parameter formatting against the REST contract."],"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"}