{"record":{"id":"b66c59d9578dddd8","repo":"apache/flink","slug":"empty-field-b66c59","errorCode":null,"errorMessage":"Empty field.","messagePattern":"Empty field\\.","errorType":"exception","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/types/parser/IntParser.java","lineNumber":129,"sourceCode":"\n    /**\n     * Static utility to parse a field of type int 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 NumberFormatException Thrown when the value cannot be parsed because the text\n     *     represents not a correct number.\n     */\n    public static final int parseField(byte[] bytes, int startPos, int length, char delimiter) {\n        long val = 0;\n        boolean neg = false;\n\n        if (bytes[startPos] == delimiter) {\n            throw new NumberFormatException(\"Empty field.\");\n        }\n\n        if (bytes[startPos] == '-') {\n            neg = true;\n            startPos++;\n            length--;\n            if (length == 0 || bytes[startPos] == delimiter) {\n                throw new NumberFormatException(\"Orphaned minus sign.\");\n            }\n        }\n\n        for (; length > 0; startPos++, length--) {\n            if (bytes[startPos] == delimiter) {\n                return (int) (neg ? -val : val);\n            }\n            if (bytes[startPos] < 48 || bytes[startPos] > 57) {\n                throw new NumberFormatException(\"Invalid character.\");\n            }","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/IntParser.java#L111-L147","documentation":"Thrown by IntParser.parseField(byte[], int, int, char) when the field starts with the delimiter byte, i.e. the column is empty. The static parser scans raw bytes and rejects an empty column immediately with NumberFormatException instead of producing a default value.","triggerScenarios":"Calling IntParser.parseField(bytes, startPos, length, delimiter) where bytes[startPos] == (byte) delimiter — e.g. \"7,,9\" with ',' delimiter: the middle empty int column throws.","commonSituations":"CSV rows with missing numeric cells (consecutive delimiters), trailing delimiter yielding an empty last field, or column misalignment after the header schema changes.","solutions":["Fix source data or delimiter handling so int columns are populated.","Guard the call: skip the record or substitute a default when the first byte equals the delimiter.","If empty cells are valid, map them explicitly (e.g. to null via a nullable wrapper) rather than calling the strict parser."],"exampleFix":"// before\nint v = IntParser.parseField(bytes, start, len, ',');\n\n// after\nint v = (len > 0 && bytes[start] == (byte) ',')\n    ? 0\n    : IntParser.parseField(bytes, start, len, ',');","handlingStrategy":"validation","validationCode":"if (len <= 0 || bytes[start] == (byte) delimiter) {\n    return 0; // or flag record as invalid\n}","typeGuard":null,"tryCatchPattern":"try {\n    int v = IntParser.parseField(bytes, start, len, delim);\n} catch (NumberFormatException e) {\n    // empty/malformed int column: side output with row context\n}","preventionTips":["Check the first byte against the delimiter before parsing.","Define empty-cell policy for int columns up front.","Validate column counts per row to catch schema drift early."],"tags":["parser","int","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"}