{"record":{"id":"6c0eb769b075e1cd","repo":"apache/flink","slug":"orphaned-minus-sign-6c0eb7","errorCode":null,"errorMessage":"Orphaned minus sign.","messagePattern":"Orphaned minus sign\\.","errorType":"exception","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/types/parser/IntParser.java","lineNumber":137,"sourceCode":"     * @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            }\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);","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/IntParser.java#L119-L155","documentation":"Thrown by IntParser.parseField when the field is a '-' sign with no digits. After consuming the minus and advancing, the parser checks length == 0 or a delimiter at the new position and rejects the sign-only field with NumberFormatException.","triggerScenarios":"Calling IntParser.parseField where the field slice is exactly \"-\" between delimiters, e.g. the row \"10,-,20\" with ',' delimiter.","commonSituations":"Placeholder '-' for missing values in exported data; truncated negative numbers from partial writes or bad slicing; hand-edited files losing digits.","solutions":["Replace sign-only placeholders in the source with real values or empty fields handled explicitly.","Pre-validate the slice: reject or default when it equals \"-\" before parsing.","Add data-quality screening for numeric fields matching ^-?\\d*$."],"exampleFix":"// before\nint v = IntParser.parseField(bytes, start, len, ',');\n\n// after\nString field = new String(bytes, start, len, StandardCharsets.UTF_8);\nif (field.equals(\"-\")) { throw new IllegalArgumentException(\"Sign-only int field at \" + start); }\nint v = IntParser.parseField(bytes, start, len, ',');","handlingStrategy":"validation","validationCode":"if (len == 1 && bytes[start] == '-') {\n    throw new IllegalArgumentException(\"Sign-only int field\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    int v = IntParser.parseField(bytes, start, len, delim);\n} catch (NumberFormatException e) {\n    if (e.getMessage().equals(\"Orphaned minus sign.\")) { /* missing value policy */ }\n    else throw e;\n}","preventionTips":["Reject or remap sign-only placeholders at ingestion.","Standardize missing-value tokens in source formats.","Screen numeric fields with ^-?\\d+$ in data-quality checks."],"tags":["parser","int","malformed-number","csv","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}