{"record":{"id":"cfdba18f428ec86b","repo":"apache/flink","slug":"empty-field","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/ByteParser.java","lineNumber":121,"sourceCode":"\n    /**\n     * Static utility to parse a field of type byte 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 byte 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 (byte) (neg ? -val : val);\n            }\n            if (bytes[startPos] < 48 || bytes[startPos] > 57) {\n                throw new NumberFormatException(\"Invalid character.\");\n            }","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/ByteParser.java#L103-L139","documentation":"Thrown by ByteParser.parseField(byte[], int, int, char) when the first byte of the field equals the delimiter, meaning the column is empty. The parser scans bytes directly and treats a delimiter at the start position as an empty field, rejecting it with NumberFormatException before any digit processing.","triggerScenarios":"Calling ByteParser.parseField(bytes, startPos, length, delimiter) where bytes[startPos] == (byte) delimiter — e.g. input \"a||c\" parsed with '|' delimiter hitting an empty middle column.","commonSituations":"CSV with consecutive delimiters (empty numeric cell), trailing delimiter on a line producing an empty last field, or a column-count mismatch after a schema change drops a column.","solutions":["Fix the input data or delimiter config so byte columns are non-empty.","Guard at the call site: if bytes[startPos] == delimiter, substitute a default or skip the record.","If empty cells are valid in your format, define an explicit mapping (empty -> 0/null) instead of parsing."],"exampleFix":"// before\nbyte v = ByteParser.parseField(bytes, start, len, '|');\n\n// after\nbyte v = (len > 0 && bytes[start] == (byte) '|')\n    ? 0\n    : ByteParser.parseField(bytes, start, len, '|');","handlingStrategy":"validation","validationCode":"if (len <= 0 || bytes[start] == (byte) delimiter) {\n    // empty column: default or explicit error\n    return 0;\n}","typeGuard":null,"tryCatchPattern":"try {\n    byte v = ByteParser.parseField(bytes, start, len, delim);\n} catch (NumberFormatException e) {\n    // empty or malformed field: emit to side output with row context\n}","preventionTips":["Check bytes[startPos] against the delimiter before parsing.","Define explicit empty-cell semantics (default value or null) for byte columns.","Keep delimiter configuration in sync with the actual file format."],"tags":["parser","byte","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"}