{"record":{"id":"cb7032357a8195a0","repo":"apache/flink","slug":"configuration-value-s-overflows-underflows-the-in","errorCode":null,"errorMessage":"Configuration value %s overflows/underflows the integer type.","messagePattern":"Configuration value (.+?) overflows/underflows the integer type\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/configuration/ConfigurationUtils.java","lineNumber":531,"sourceCode":"    }\n\n    static String convertToString(Object o) {\n        if (o.getClass() == String.class) {\n            return (String) o;\n        } else {\n            return YamlParserUtils.toYAMLString(o);\n        }\n    }\n\n    static Integer convertToInt(Object o) {\n        if (o.getClass() == Integer.class) {\n            return (Integer) o;\n        } else if (o.getClass() == Long.class) {\n            long value = (Long) o;\n            if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {\n                return (int) value;\n            } else {\n                throw new IllegalArgumentException(\n                        String.format(\n                                \"Configuration value %s overflows/underflows the integer type.\",\n                                value));\n            }\n        }\n\n        return Integer.parseInt(o.toString());\n    }\n\n    static Long convertToLong(Object o) {\n        if (o.getClass() == Long.class) {\n            return (Long) o;\n        } else if (o.getClass() == Integer.class) {\n            return ((Integer) o).longValue();\n        }\n\n        return Long.parseLong(o.toString());\n    }","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/configuration/ConfigurationUtils.java#L513-L549","documentation":"Thrown by convertToInt when the raw value is a Long that falls outside the 32-bit signed integer range (less than Integer.MIN_VALUE or greater than Integer.MAX_VALUE). This happens when a YAML parser produces a Long for large numeric literals and the target ConfigOption is Integer-typed.","triggerScenarios":"Declaring ConfigOption<Integer> and supplying a value that YAML parses as a Long because it exceeds Integer.MAX_VALUE (e.g., 3000000000). The guard at convertToInt checks bounds before the narrowing cast.","commonSituations":"Setting memory or port values that accidentally exceed int range. Typing an extra zero in a numeric config. Using a Long literal where an int was intended.","solutions":["Change the ConfigOption type to Long if the value legitimately exceeds int range.","Correct the value to fit within Integer range if an int is genuinely required.","Check for stray digits or incorrect units in the config value."],"exampleFix":"// before\nConfigOption<Integer> opt = ConfigOptions.key(\"my.value\").intType().defaultValue(0);\n// value in yaml: my.value: 3000000000\n\n// after\nConfigOption<Long> opt = ConfigOptions.key(\"my.value\").longType().defaultValue(0L);","handlingStrategy":"validation","validationCode":"long candidate = Long.parseLong(rawValue);\nif (candidate < Integer.MIN_VALUE || candidate > Integer.MAX_VALUE) {\n    throw new IllegalArgumentException(\"Value \" + candidate + \" exceeds int range\");\n}","typeGuard":"static boolean fitsInInt(long v) { return v >= Integer.MIN_VALUE && v <= Integer.MAX_VALUE; }","tryCatchPattern":"try {\n    config.setInt(option, rawValue);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"overflows/underflows the integer\")) { /* use long or fix */ }\n}","preventionTips":["Use Long-typed ConfigOptions for values that may exceed int range.","Validate numeric ranges before setting config.","Double-check exponents and digit counts."],"tags":["configuration","type-conversion","numeric-overflow"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}