{"record":{"id":"995922de66fe52dc","repo":"apache/flink","slug":"invalid-input-empty-string-995922","errorCode":null,"errorMessage":"Invalid input: Empty string","messagePattern":"Invalid input: Empty string","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java","lineNumber":226,"sourceCode":"            endPos++;\n        }\n\n        if (endPos == startPos) {\n            setErrorState(ParseErrorState.EMPTY_COLUMN);\n            return -1;\n        }\n        return endPos;\n    }\n\n    /**\n     * Returns the length of a string. Throws an exception if the column is empty.\n     *\n     * @return the length of the string\n     */\n    protected static final int nextStringLength(\n            byte[] bytes, int startPos, int length, char delimiter) {\n        if (length <= 0) {\n            throw new IllegalArgumentException(\"Invalid input: Empty string\");\n        }\n        int limitedLength = 0;\n        final byte delByte = (byte) delimiter;\n\n        while (limitedLength < length && bytes[startPos + limitedLength] != delByte) {\n            limitedLength++;\n        }\n\n        return limitedLength;\n    }\n\n    /**\n     * Gets the character set used for this parser.\n     *\n     * @return the charset used for this parser.\n     */\n    public Charset getCharset() {\n        return this.charset;","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java#L208-L244","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nint len = FieldParser.nextStringLength(bytes, start, length, delim); // length may be 0\n\n// after\nif (length <= 0) { throw new IllegalArgumentException(\"Empty numeric column at position \" + start); }\nint len = FieldParser.nextStringLength(bytes, start, length, delim);","handlingStrategy":"validation","validationCode":"if (length <= 0) {\n    throw new IllegalArgumentException(\"Empty field region at start=\" + startPos);\n}","typeGuard":null,"tryCatchPattern":"try {\n    int len = FieldParser.nextStringLength(bytes, start, length, delim);\n} catch (IllegalArgumentException e) {\n    // empty column: default or skip record\n}","preventionTips":["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."],"tags":["parser","fieldparser","empty-field","validation","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}