{"record":{"id":"7dfc4225d04738d9","repo":"apache/flink","slug":"value-overflow-underflow","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/ByteParser.java","lineNumber":144,"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 (byte) (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 > Byte.MAX_VALUE && (!neg || val > -Byte.MIN_VALUE)) {\n                throw new NumberFormatException(\"Value overflow/underflow\");\n            }\n        }\n        return (byte) (neg ? -val : val);\n    }\n}\n","sourceCodeStart":126,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/types/parser/ByteParser.java#L126-L150","documentation":"Thrown by ByteParser.parseField when the accumulated value leaves the byte range. Digits are accumulated into a long; after each step the parser checks val > Byte.MAX_VALUE (and for negatives val > -Byte.MIN_VALUE, i.e. 128) and rejects values that cannot round-trip into a signed byte (-128..127).","triggerScenarios":"Calling ByteParser.parseField with a field like \"128\", \"200\", or \"-129\" — numerically valid integers that overflow the byte target type.","commonSituations":"Column type mismatch: a TINYINT/byte field receiving small-int data that drifted above 127 or below -128; unit tests using convenient values like 255 or 1000; schema evolution moving a field from byte to int without updating the parser config.","solutions":["Widen the target type: use IntParser/LongParser (and INT/BIGINT types) for values outside -128..127.","Clamp or pre-check the parsed integer range before assigning to a byte column if the domain genuinely fits.","Fix the source data if values above 127 in a byte column are producer bugs."],"exampleFix":"// before\nbyte v = ByteParser.parseField(bytes, start, len, '|'); // fails on \"200\"\n\n// after\nint v = IntParser.parseField(bytes, start, len, '|'); // widen target type","handlingStrategy":"validation","validationCode":"long candidate = Long.parseLong(new String(bytes, start, len, StandardCharsets.UTF_8));\nif (candidate < Byte.MIN_VALUE || candidate > Byte.MAX_VALUE) {\n    throw new IllegalArgumentException(\"Value out of byte range: \" + candidate);\n}","typeGuard":null,"tryCatchPattern":"try {\n    byte v = ByteParser.parseField(bytes, start, len, delim);\n} catch (NumberFormatException e) {\n    if (e.getMessage().equals(\"Value overflow/underflow\")) {\n        int wider = IntParser.parseField(bytes, start, len, delim); // widen instead\n    } else throw e;\n}","preventionTips":["Match column type to the real value range; prefer int/long for IDs and counters.","Range-check parsed values before narrowing to byte.","Review TINYINT columns whenever source data grows."],"tags":["parser","byte","overflow","csv","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}