apache/hadoop · warning · BadRequestException
Invalid number format: {}
Error message
Invalid number format: {} What it means
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.
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsWebServices.java:210
init();
if (count != null && !count.isEmpty()) {
try {
countParam = Long.parseLong(count);
} catch (NumberFormatException e) {
throw new BadRequestException(e.getMessage());
}
if (countParam <= 0) {
throw new BadRequestException("limit value must be greater then 0");
}
}
Long sBegin = null;
if (startedBegin != null && !startedBegin.isEmpty()) {
try {
sBegin = Long.parseLong(startedBegin);
} catch (NumberFormatException e) {
throw new BadRequestException("Invalid number format: " + e.getMessage());
}
if (sBegin < 0) {
throw new BadRequestException("startedTimeBegin must be greater than 0");
}
}
Long sEnd = null;
if (startedEnd != null && !startedEnd.isEmpty()) {
try {
sEnd = Long.parseLong(startedEnd);
} catch (NumberFormatException e) {
throw new BadRequestException("Invalid number format: " + e.getMessage());
}
if (sEnd < 0) {
throw new BadRequestException("startedTimeEnd must be greater than 0");
}
}
if (sBegin != null && sEnd != null && sBegin > sEnd) {View on GitHub (pinned to 2add963021)
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.
Example fix
# before curl 'http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=2024-01-01' # HTTP 400 # after curl "http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=$(date -d '2024-01-01' +%s000)"
Defensive patterns
Strategy: validation
Validate before calling
function toEpochMillis(v: string | number | Date): string {
const n = v instanceof Date ? v.getTime()
: typeof v === 'number' ? v
: /^\d+$/.test(v) ? Number(v)
: NaN;
if (!Number.isInteger(n) || n < 0) {
throw new TypeError(`not epoch millis: ${String(v)}`);
}
return String(n);
}
const url = `http://jhs:19888/ws/v1/history/jobs?startedTimeBegin=${toEpochMillis(begin)}`; Type guard
function isEpochMillis(v: unknown): v is number {
return typeof v === 'number' && Number.isInteger(v) && v >= 0;
} Prevention
- 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.
When it happens
Trigger: startedTimeBegin=2024-01-01 (date string instead of epoch millis); decimal, localized, or scientific-notation values; values with units or stray characters.
Common situations: Clients passing ISO dates or formatted timestamps; locale-specific number formatting; values copied from UI time pickers.
Related errors
- limit value must be greater then 0
- startedTimeBegin must be greater than 0
- Parameter [{0}], invalid value [{1}], value must be [{2}]
- Invalid blacklistDisablePercent: {}. Should be an integer be
- job, {}, is not found
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/3c0ce32472dc8f3b.
Report an issue: GitHub.