{"record":{"id":"8eb08652b56d2775","repo":"apache/flink","slug":"empty-field-8eb086","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/LongParser.java","lineNumber":137,"sourceCode":"\n    /**\n     * Static utility to parse a field of type long 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 long 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 neg ? -val : val;\n            }\n            if (bytes[startPos] < 48 || bytes[startPos] > 57) {\n                throw new NumberFormatException(\"Invalid character.\");\n            }","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/LongParser.java#L119-L155","documentation":"Thrown by LongParser.parseField(byte[], int, int, char) when the first byte of the field equals the delimiter, i.e. an empty column. Like the other integer parsers it scans raw bytes and rejects empty long fields immediately with NumberFormatException rather than returning a default.","triggerScenarios":"Calling LongParser.parseField(bytes, startPos, length, delimiter) where bytes[startPos] == (byte) delimiter — an empty long column between delimiters, e.g. \"1||3\" with '|'.","commonSituations":"Missing values in CSV exports rendered as empty cells; trailing delimiter creating an empty last field; column misalignment after schema changes.","solutions":["Populate or default the long column in the source data.","Guard the call site: when the first byte is the delimiter, skip the record or substitute a default.","Handle legitimately-missing values explicitly before invoking the strict parser."],"exampleFix":"// before\nlong v = LongParser.parseField(bytes, start, len, '|');\n\n// after\nlong v = (len > 0 && bytes[start] == (byte) '|')\n    ? 0L\n    : LongParser.parseField(bytes, start, len, '|');","handlingStrategy":"validation","validationCode":"if (len <= 0 || bytes[start] == (byte) delimiter) {\n    return 0L; // or flag record as invalid\n}","typeGuard":null,"tryCatchPattern":"try {\n    long v = LongParser.parseField(bytes, start, len, delim);\n} catch (NumberFormatException e) {\n    // empty/malformed long column: side output with row context\n}","preventionTips":["Check the first byte against the delimiter before parsing.","Define empty-cell handling for long columns explicitly.","Validate delimiter configuration against the actual file format."],"tags":["parser","long","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"}