{"record":{"id":"fddbc4a75259f9e8","repo":"apache/flink","slug":"invalid-character-fddbc4","errorCode":null,"errorMessage":"Invalid character.","messagePattern":"Invalid character\\.","errorType":"exception","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/types/parser/LongParser.java","lineNumber":154,"sourceCode":"        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            }\n            val *= 10;\n            val += bytes[startPos] - 48;\n\n            // check for overflow / underflow\n            if (val < 0) {\n                // this is an overflow/underflow, unless we hit exactly the Long.MIN_VALUE\n                if (neg && val == Long.MIN_VALUE) {\n                    if (length == 1 || bytes[startPos + 1] == delimiter) {\n                        return Long.MIN_VALUE;\n                    } else {\n                        throw new NumberFormatException(\"value overflow\");\n                    }\n                } else {\n                    throw new NumberFormatException(\"value overflow\");\n                }\n            }\n        }","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/LongParser.java#L136-L172","documentation":"Thrown by LongParser.parseField when a byte inside the field is not an ASCII digit. The digit loop accepts only '0'..'9' after an optional leading '-'; separators, '+', '.', whitespace, or letters trigger this NumberFormatException before any overflow checking.","triggerScenarios":"Calling LongParser.parseField with fields like \"1,000,000\", \"+9\", \"123 \", or \"9.5\" — any non-digit byte before the delimiter at LongParser.java:155.","commonSituations":"Grouping separators in spreadsheet/BI exports; decimal or scientific values in a long column; stray padding; schema drift changing column formats.","solutions":["Emit plain digit-only integers for long columns at the producer.","Parse formatted/fractional input via BigDecimal first, validate, then convert to long.","Pre-scan fields for non-digit bytes and divert bad records to a dead-letter path."],"exampleFix":"// before\nlong v = LongParser.parseField(bytes, start, len, '|'); // fails on \"1,000,000\"\n\n// after\nString field = new String(bytes, start, len, StandardCharsets.UTF_8).replace(\",\", \"\");\nlong v = Long.parseLong(field.trim());","handlingStrategy":"validation","validationCode":"for (int i = 0; i < len; i++) {\n    byte b = bytes[start + i];\n    if (b == (byte) delimiter) break;\n    if (b < 48 || b > 57) throw new IllegalArgumentException(\"Non-digit byte in long field: \" + (char) b);\n}","typeGuard":null,"tryCatchPattern":"try {\n    long v = LongParser.parseField(bytes, start, len, delim);\n} catch (NumberFormatException e) {\n    String raw = new String(bytes, start, len, StandardCharsets.UTF_8);\n    long v = Long.parseLong(raw.replace(\",\", \"\").trim()); // fallback for formatted input\n}","preventionTips":["Emit digit-only integers for long columns.","Pre-validate non-digit bytes for untrusted input.","Send malformed records to a reprocessing path rather than crashing."],"tags":["parser","long","invalid-character","csv","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}