{"record":{"id":"15b502421e4bd58e","repo":"apache/flink","slug":"value-overflow-underflow-15b502","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/IntParser.java","lineNumber":152,"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 (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":134,"sourceCodeEnd":158,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/IntParser.java#L134-L158","documentation":"Thrown by IntParser.parseField when the accumulated value exceeds the int range. Digits are accumulated in a long and checked against OVERFLOW_BOUND/UNDERFLOW_BOUND each step, so any field whose numeric value falls outside [-2147483648, 2147483647] is rejected early with NumberFormatException.","triggerScenarios":"Calling IntParser.parseField with fields like \"3000000000\" or \"-3000000000\" — integers too large for a Java int.","commonSituations":"IDs (user/product/transaction IDs) growing beyond 2^31-1 and still declared INT; column type mismatch where a BIGINT source feeds an int field; year 2038-style timestamp values in seconds.","solutions":["Switch the target type to long: use LongParser.parseField and a BIGINT/long schema for the column.","If IDs must stay int-width, remap/hash them at the producer to fit the range.","Fix upstream data if out-of-range values in an int column are producer bugs."],"exampleFix":"// before\nint v = IntParser.parseField(bytes, start, len, '|'); // fails on \"3000000000\"\n\n// after\nlong v = LongParser.parseField(bytes, start, len, '|'); // widen to long","handlingStrategy":"validation","validationCode":"String raw = new String(bytes, start, len, StandardCharsets.UTF_8);\nlong candidate = Long.parseLong(raw);\nif (candidate < Integer.MIN_VALUE || candidate > Integer.MAX_VALUE) {\n    throw new IllegalArgumentException(\"Value out of int range: \" + candidate);\n}","typeGuard":null,"tryCatchPattern":"try {\n    int v = IntParser.parseField(bytes, start, len, delim);\n} catch (NumberFormatException e) {\n    if (e.getMessage().equals(\"Value overflow/underflow\")) {\n        long wider = LongParser.parseField(bytes, start, len, delim); // widen instead\n    } else throw e;\n}","preventionTips":["Declare growing ID columns as BIGINT/long, not INT.","Range-check before narrowing parsed integers.","Monitor source value ranges when schemas evolve."],"tags":["parser","int","overflow","csv","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}