{"record":{"id":"ab77ddcf4cb5713b","repo":"apache/flink","slug":"invalid-character-ab77dd","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/IntParser.java","lineNumber":146,"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 (int) (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            if (val > OVERFLOW_BOUND && (!neg || val > UNDERFLOW_BOUND)) {\n                throw new NumberFormatException(\"Value overflow/underflow\");\n            }\n        }\n        return (int) (neg ? -val : val);\n    }\n}\n","sourceCodeStart":128,"sourceCodeEnd":158,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/IntParser.java#L128-L158","documentation":"Thrown by IntParser.parseField when a byte inside the field is not an ASCII digit. The digit loop accepts only '0'..'9' (byte range 48-57) after an optional leading '-'; grouping separators, '+', '.', whitespace, or letters all trigger this NumberFormatException.","triggerScenarios":"Calling IntParser.parseField with fields like \"1,000\", \"+7\", \"12 \", \"3.0\", or \"1e5\" — any non-digit byte before the delimiter at IntParser.java:147.","commonSituations":"Locale-formatted numbers from spreadsheets/BI exports; decimal strings fed to an int column; hex or scientific notation; schema drift changing a column's content format.","solutions":["Produce plain unformatted integers for int columns (no separators, no plus sign, no exponent).","If values may be formatted or fractional, parse via BigDecimal first, validate scale, then narrow.","Route fields failing a non-digit pre-scan to a side output for reprocessing."],"exampleFix":"// before\nint v = IntParser.parseField(bytes, start, len, '|'); // fails on \"1,000\"\n\n// after\nString field = new String(bytes, start, len, StandardCharsets.UTF_8).replace(\",\", \"\");\nint v = Integer.parseInt(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 int field: \" + (char) b);\n}","typeGuard":null,"tryCatchPattern":"try {\n    int v = IntParser.parseField(bytes, start, len, delim);\n} catch (NumberFormatException e) {\n    String raw = new String(bytes, start, len, StandardCharsets.UTF_8);\n    int v = Integer.parseInt(raw.replace(\",\", \"\").trim()); // fallback for formatted input\n}","preventionTips":["Produce digit-only integers for int columns.","Pre-scan for non-digit bytes when input format is not controlled.","Divert malformed records to a dead-letter path instead of failing the job."],"tags":["parser","int","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"}