{"record":{"id":"adb64b3dae9b41e2","repo":"apache/flink","slug":"configuration-value-s-overflows-underflows-the-fl","errorCode":null,"errorMessage":"Configuration value %s overflows/underflows the float type.","messagePattern":"Configuration value (.+?) overflows/underflows the float type\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/configuration/ConfigurationUtils.java","lineNumber":579,"sourceCode":"            default:\n                throw new IllegalArgumentException(\n                        String.format(\n                                \"Unrecognized option for boolean: %s. Expected either true or false(case insensitive)\",\n                                o));\n        }\n    }\n\n    static Float convertToFloat(Object o) {\n        if (o.getClass() == Float.class) {\n            return (Float) o;\n        } else if (o.getClass() == Double.class) {\n            double value = ((Double) o);\n            if (value == 0.0\n                    || (value >= Float.MIN_VALUE && value <= Float.MAX_VALUE)\n                    || (value >= -Float.MAX_VALUE && value <= -Float.MIN_VALUE)) {\n                return (float) value;\n            } else {\n                throw new IllegalArgumentException(\n                        String.format(\n                                \"Configuration value %s overflows/underflows the float type.\",\n                                value));\n            }\n        }\n\n        return Float.parseFloat(o.toString());\n    }\n\n    static Double convertToDouble(Object o) {\n        if (o.getClass() == Double.class) {\n            return (Double) o;\n        } else if (o.getClass() == Float.class) {\n            return ((Float) o).doubleValue();\n        }\n\n        return Double.parseDouble(o.toString());\n    }","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/configuration/ConfigurationUtils.java#L561-L597","documentation":"Thrown by convertToFloat when the raw value is a Double whose magnitude exceeds Float.MAX_VALUE or underflows below Float.MIN_VALUE (excluding zero). This guard prevents silent precision/range loss when narrowing a Double to a Float.","triggerScenarios":"Declaring ConfigOption<Float> and supplying a value that YAML parses as a Double because it is outside the float range (e.g., 1e40 or 1e-50). The bound check in convertToFloat rejects out-of-range doubles.","commonSituations":"Setting thresholds or scaling factors with very large or very small exponents. Mixing double-literal syntax in configs targeting float options.","solutions":["Change the ConfigOption type to Double if the value legitimately exceeds float precision/range.","Adjust the value to stay within Float range.","Verify the exponent magnitude is what you intended."],"exampleFix":"// before\nConfigOption<Float> opt = ConfigOptions.key(\"my.factor\").floatType().defaultValue(1.0f);\n// value: my.factor: 1e40\n\n// after\nConfigOption<Double> opt = ConfigOptions.key(\"my.factor\").doubleType().defaultValue(1.0);","handlingStrategy":"validation","validationCode":"double candidate = Double.parseDouble(rawValue);\nif (candidate != 0.0 && (Math.abs(candidate) > Float.MAX_VALUE || (Math.abs(candidate) < Float.MIN_VALUE))) {\n    throw new IllegalArgumentException(\"Value exceeds float range\");\n}","typeGuard":"static boolean fitsInFloat(double v) {\n    return v == 0.0 || (Math.abs(v) >= Float.MIN_VALUE && Math.abs(v) <= Float.MAX_VALUE);\n}","tryCatchPattern":"try {\n    config.set(floatOption, rawValue);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"overflows/underflows the float\")) { /* use double */ }\n}","preventionTips":["Use Double-typed ConfigOptions when precision/range may exceed float.","Validate exponent magnitude for float options.","Prefer double for scientific thresholds."],"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"}