apache/flink · error · NumberFormatException
Value overflow/underflow
Error message
Value overflow/underflow
What it means
Thrown by ByteParser.parseField when the accumulated value leaves the byte range. Digits are accumulated into a long; after each step the parser checks val > Byte.MAX_VALUE (and for negatives val > -Byte.MIN_VALUE, i.e. 128) and rejects values that cannot round-trip into a signed byte (-128..127).
Source
Thrown at flink-core/src/main/java/org/apache/flink/types/parser/ByteParser.java:144
startPos++;
length--;
if (length == 0 || bytes[startPos] == delimiter) {
throw new NumberFormatException("Orphaned minus sign.");
}
}
for (; length > 0; startPos++, length--) {
if (bytes[startPos] == delimiter) {
return (byte) (neg ? -val : val);
}
if (bytes[startPos] < 48 || bytes[startPos] > 57) {
throw new NumberFormatException("Invalid character.");
}
val *= 10;
val += bytes[startPos] - 48;
if (val > Byte.MAX_VALUE && (!neg || val > -Byte.MIN_VALUE)) {
throw new NumberFormatException("Value overflow/underflow");
}
}
return (byte) (neg ? -val : val);
}
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Widen the target type: use IntParser/LongParser (and INT/BIGINT types) for values outside -128..127.
- Clamp or pre-check the parsed integer range before assigning to a byte column if the domain genuinely fits.
- Fix the source data if values above 127 in a byte column are producer bugs.
Example fix
// before byte v = ByteParser.parseField(bytes, start, len, '|'); // fails on "200" // after int v = IntParser.parseField(bytes, start, len, '|'); // widen target type
Defensive patterns
Strategy: validation
Validate before calling
long candidate = Long.parseLong(new String(bytes, start, len, StandardCharsets.UTF_8));
if (candidate < Byte.MIN_VALUE || candidate > Byte.MAX_VALUE) {
throw new IllegalArgumentException("Value out of byte range: " + candidate);
} Try / catch
try {
byte v = ByteParser.parseField(bytes, start, len, delim);
} catch (NumberFormatException e) {
if (e.getMessage().equals("Value overflow/underflow")) {
int wider = IntParser.parseField(bytes, start, len, delim); // widen instead
} else throw e;
} Prevention
- Match column type to the real value range; prefer int/long for IDs and counters.
- Range-check parsed values before narrowing to byte.
- Review TINYINT columns whenever source data grows.
When it happens
Trigger: Calling ByteParser.parseField with a field like "128", "200", or "-129" — numerically valid integers that overflow the byte target type.
Common situations: Column type mismatch: a TINYINT/byte field receiving small-int data that drifted above 127 or below -128; unit tests using convenient values like 255 or 1000; schema evolution moving a field from byte to int without updating the parser config.
Related errors
- Empty field.
- Orphaned minus sign.
- Invalid character.
- Value overflow/underflow
- Invalid input: Empty string
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/7dfc4225d04738d9.
Report an issue: GitHub.