{"record":{"id":"efb2f49686d1cff0","repo":"apache/flink","slug":"orphaned-minus-sign-efb2f4","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/ShortParser.java","lineNumber":136,"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 short 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 (short) (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","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/ShortParser.java#L118-L154","documentation":"ShortParser.parseField throws NumberFormatException(\"Orphaned minus sign.\") when the field starts with '-' but has no digits after it — either the minus is the entire field or it is immediately followed by the delimiter.","triggerScenarios":"A CSV short field containing just '-' (e.g. '5,-,7'), or '-' immediately before the delimiter after the sign-consumption step. The parser advances startPos past '-' and then finds length==0 or the delimiter byte.","commonSituations":"Data quality issues where '-' is used as a placeholder for missing/unknown values; truncation of negative numbers during export; user-typed placeholders in generated test files.","solutions":["Replace bare '-' placeholders in the source data with a proper value or an explicit null literal","Configure the CSV connector's null-literal handling if '-' denotes missing","Validate/clean fields before they reach a SMALLINT-typed parser"],"exampleFix":"// before\n-- CSV: 5,-,7 with schema (a SMALLINT, b SMALLINT, c SMALLINT)\n\n// after\n-- CSV: 5,\\N,7 with null-literal configured, or 5,0,7","handlingStrategy":"validation","validationCode":"if (field.equals(\"-\") || field.endsWith(\"-\") && field.length() == 1) {\n    /* placeholder: map to null */\n}","typeGuard":null,"tryCatchPattern":"catch (NumberFormatException e) { log.info(\"placeholder '-' in short field: {}\", rawLine); }","preventionTips":["Ban bare '-' as a missing-value marker in data contracts","Validate exported files contain [-]?[0-9]+ only for numeric columns"],"tags":["parsing","csv","short","data-quality","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}