{"record":{"id":"e911b9c79d4cfe1b","repo":"apache/flink","slug":"invalid-input-empty-string","errorCode":null,"errorMessage":"Invalid input: Empty string","messagePattern":"Invalid input: Empty string","errorType":"exception","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/types/parser/BigDecParser.java","lineNumber":109,"sourceCode":"        return parseField(bytes, startPos, length, (char) 0xffff);\n    }\n\n    /**\n     * Static utility to parse a field of type BigDecimal from a byte sequence that represents text\n     * characters (such as when read from a file stream).\n     *\n     * @param bytes The bytes containing the text data that should be parsed.\n     * @param startPos The offset to start the parsing.\n     * @param length The length of the byte sequence (counting from the offset).\n     * @param delimiter The delimiter that terminates the field.\n     * @return The parsed value.\n     * @throws IllegalArgumentException Thrown when the value cannot be parsed because the text\n     *     represents not a correct number.\n     */\n    public static final BigDecimal parseField(\n            byte[] bytes, int startPos, int length, char delimiter) {\n        if (length <= 0) {\n            throw new NumberFormatException(\"Invalid input: Empty string\");\n        }\n        int i = 0;\n        final byte delByte = (byte) delimiter;\n\n        while (i < length && bytes[startPos + i] != delByte) {\n            i++;\n        }\n\n        if (i > 0\n                && (Character.isWhitespace(bytes[startPos])\n                        || Character.isWhitespace(bytes[startPos + i - 1]))) {\n            throw new NumberFormatException(\n                    \"There is leading or trailing whitespace in the numeric field.\");\n        }\n\n        final char[] chars = new char[i];\n        for (int j = 0; j < i; j++) {\n            final byte b = bytes[startPos + j];","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/BigDecParser.java#L91-L127","documentation":"Thrown by BigDecParser.parseField(byte[], int, int, char) when the field length is zero or negative. Before any numeric parsing happens, the parser guards length <= 0 and rejects the field as an empty string with a NumberFormatException. This is the static parseField variant used for delimiter-separated text; it throws rather than returning a null-parsed flag like the FieldParser entry points.","triggerScenarios":"Calling BigDecParser.parseField(bytes, startPos, length, delimiter) with length == 0 — an empty column in a delimited text row — or a negative length from an upstream offset miscalculation.","commonSituations":"CSV/text input with trailing delimiters or consecutive delimiters creating empty columns; a header/format mismatch where the parsed column positions drift; unit tests feeding empty arrays.","solutions":["Fix the source data or the field extraction so numeric columns are never empty (fill defaults or correct delimiter configuration).","Guard the call site: skip or default the field when length <= 0 before invoking parseField.","If empty numeric columns are legitimate in your format, treat them explicitly (e.g. map to null/zero) instead of relying on the parser."],"exampleFix":"// before\nBigDecimal v = BigDecParser.parseField(bytes, start, len, '|'); // len may be 0\n\n// after\nBigDecimal v = (len <= 0)\n    ? null\n    : BigDecParser.parseField(bytes, start, len, '|');","handlingStrategy":"validation","validationCode":"if (length <= 0) {\n    // empty column: skip, default, or raise a domain error with row context\n    throw new IllegalArgumentException(\"Empty BigDecimal column\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    BigDecimal v = BigDecParser.parseField(bytes, start, len, delim);\n} catch (NumberFormatException e) {\n    // route record to side output / dead letter with row context\n}","preventionTips":["Check column length before calling static parseField helpers.","Prefer the instance FieldParser API which reports errors via ParseErrorState instead of throwing.","Validate CSV schemas (column counts, emptiness) on ingest."],"tags":["parser","bigdecimal","empty-field","csv","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}