apache/flink · error · IllegalArgumentException
Invalid input: Empty string
Error message
Invalid input: Empty string
What it means
Thrown by FieldParser.nextStringLength(byte[], int, int, char), the shared helper used by BigDec/BigInt/Double/Float parsers, when length <= 0. Unlike the instance-level parse entry points (which set ParseErrorState and return a status), this static helper throws IllegalArgumentException for an empty input region.
Source
Thrown at flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java:226
endPos++;
}
if (endPos == startPos) {
setErrorState(ParseErrorState.EMPTY_COLUMN);
return -1;
}
return endPos;
}
/**
* Returns the length of a string. Throws an exception if the column is empty.
*
* @return the length of the string
*/
protected static final int nextStringLength(
byte[] bytes, int startPos, int length, char delimiter) {
if (length <= 0) {
throw new IllegalArgumentException("Invalid input: Empty string");
}
int limitedLength = 0;
final byte delByte = (byte) delimiter;
while (limitedLength < length && bytes[startPos + limitedLength] != delByte) {
limitedLength++;
}
return limitedLength;
}
/**
* Gets the character set used for this parser.
*
* @return the charset used for this parser.
*/
public Charset getCharset() {
return this.charset;View on GitHub (pinned to 2f3c205e92)
Solutions
- Check length > 0 (and that the field is not just the delimiter) before calling the static parseField helpers.
- Fix the record-splitting logic if lengths are computed wrong (off-by-one at row boundaries).
- Prefer the instance FieldParser API (parseField returning boolean with getErrorState) for per-row error handling instead of the throwing static helpers.
Example fix
// before
int len = FieldParser.nextStringLength(bytes, start, length, delim); // length may be 0
// after
if (length <= 0) { throw new IllegalArgumentException("Empty numeric column at position " + start); }
int len = FieldParser.nextStringLength(bytes, start, length, delim); Defensive patterns
Strategy: validation
Validate before calling
if (length <= 0) {
throw new IllegalArgumentException("Empty field region at start=" + startPos);
} Try / catch
try {
int len = FieldParser.nextStringLength(bytes, start, length, delim);
} catch (IllegalArgumentException e) {
// empty column: default or skip record
} Prevention
- Verify length > 0 before calling nextStringLength or the static parseField helpers.
- Prefer the instance FieldParser API with ParseErrorState for row-level error reporting.
- Unit-test splitting logic around delimiters and row boundaries.
When it happens
Trigger: Calling nextStringLength directly, or invoking the static parseField of BigIntParser/BigDecParser/DoubleParser/FloatParser with length == 0 — an empty column between delimiters or a miscomputed length argument.
Common situations: Empty numeric columns in delimited text; off-by-one errors in custom splitting code passing zero/negative lengths; trailing-delimiter rows yielding an empty final field.
Related errors
- Invalid input: Empty string
- Empty field.
- Empty field.
- Empty field.
- The output size cannot be smaller than zero.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/995922de66fe52dc.
Report an issue: GitHub.