{"record":{"id":"03e783986170a894","repo":"apache/flink","slug":"value-overflow-underflow-03e783","errorCode":null,"errorMessage":"Value overflow/underflow","messagePattern":"Value overflow/underflow","errorType":"exception","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/types/parser/ShortParser.java","lineNumber":151,"sourceCode":"            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\n        return (short) (neg ? -val : val);\n    }\n}\n","sourceCodeStart":133,"sourceCodeEnd":158,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/ShortParser.java#L133-L158","documentation":"ShortParser.parseField throws NumberFormatException(\"Value overflow/underflow\") when the accumulated value exceeds what a 16-bit signed short can hold (positive bound 32767, negative bound 32768 magnitude). The parser accumulates into a long and checks against OVERFLOW_BOUND/UNDERFLOW_BOUND after each digit.","triggerScenarios":"A CSV field assigned SHORT type containing a value outside [-32768, 32767], e.g. '40000' or '-50000'. Note the bound check runs only when a delimiter or end-of-field is processed per digit; values just past the bound trigger on the offending digit.","commonSituations":"Schema type mismatch: source data actually contains ints/longs (counts, ports near 65535, years+ids) but the column was declared SMALLINT; upstream widened a field without notice; delimited parsing merges two small numbers into one ('12' '345' read as '12345' due to a delimiter bug).","solutions":["Change the column type from SMALLINT to INT or BIGINT to match real data ranges","Audit the actual min/max of the column in the source file and align the schema","Check delimiter configuration if merged fields are producing inflated numbers","Clamp or reject out-of-range values in a cleaning step if SHORT is a hard requirement"],"exampleFix":"// before\nDataTypes.FIELD(\"port_history_count\", DataTypes.SMALLINT())\n\n// after\nDataTypes.FIELD(\"port_history_count\", DataTypes.INT())","handlingStrategy":"validation","validationCode":"int v = Integer.parseInt(field);\nif (v < Short.MIN_VALUE || v > Short.MAX_VALUE) throw new IllegalArgumentException(\"out of short range: \" + v);","typeGuard":null,"tryCatchPattern":"catch (NumberFormatException e) { /* widen schema to INT and reprocess */ }","preventionTips":["Profile column ranges before choosing SMALLINT","Prefer INT for any count-like field that can grow","Check delimiter config when values look implausibly large"],"tags":["parsing","csv","short","overflow","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}