{"id":"76f9466185556a76","repo":"apache/kafka","slug":"value-must-be-no-more-than-max","errorCode":null,"errorMessage":"Value must be no more than max","messagePattern":"Value must be no more than max","errorType":"validation","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java","lineNumber":1015,"sourceCode":"        public static Range atLeast(Number min) {\n            return new Range(min, null);\n        }\n\n        /**\n         * A numeric range that checks both the upper (inclusive) and lower bound\n         */\n        public static Range between(Number min, Number max) {\n            return new Range(min, max);\n        }\n\n        public void ensureValid(String name, Object o) {\n            if (o == null)\n                throw new ConfigException(name, null, \"Value must be non-null\");\n            Number n = (Number) o;\n            if (min != null && n.doubleValue() < min.doubleValue())\n                throw new ConfigException(name, o, \"Value must be at least \" + min);\n            if (max != null && n.doubleValue() > max.doubleValue())\n                throw new ConfigException(name, o, \"Value must be no more than \" + max);\n        }\n\n        public String toString() {\n            if (min == null && max == null)\n                return \"[...]\";\n            else if (min == null)\n                return \"[...,\" + max + \"]\";\n            else if (max == null)\n                return \"[\" + min + \",...]\";\n            else\n                return \"[\" + min + \",...,\" + max + \"]\";\n        }\n    }\n\n    public static class ValidList implements Validator {\n\n        final ValidString validString;\n        final boolean isEmptyAllowed;","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java#L997-L1033","documentation":"Thrown by Range.ensureValid when a numeric value exceeds the upper bound declared via Range.between(min,max). It enforces a maximum acceptable value for bounded numeric configs (e.g. default.api.timeout.ms upper limit, fetch.max.partition.bytes ceiling, max.poll.interval.ms upper bound in some validators). The bound value is appended so the developer knows the ceiling.","triggerScenarios":"Calling ConfigDef.validate or constructing a client with a numeric config above the documented maximum — e.g. fetch.max.bytes above Integer.MAX_VALUE-1, max.partition.fetch.bytes above the ceiling, a custom bounded config exceeded.","commonSituations":"Trying to lift a memory/size limit beyond what the broker protocol can carry (e.g. fetch.max.bytes above ~2GB); operator copy-paste from a tutorial that suggested an enormous value; unit confusion (passing bytes instead of KiB, or ms instead of seconds) producing a huge number; version migration where an upper bound was introduced.","solutions":["Set the value to no more than the documented maximum (shown in the message).","Double-check the documented unit (bytes vs KiB, ms vs seconds) — a unit mismatch is the usual cause of a too-large value.","If you genuinely need more, check whether a different config (e.g. fetch.max.bytes vs max.message.bytes) is the correct knob.","Upgrade or check KIP notes: ceilings are occasionally raised across versions."],"exampleFix":"// before\nprops.put(ConsumerConfig.FETCH_MAX_BYTES_CONFIG,\n         5_000_000_000L); // > Integer.MAX_VALUE-1\n// -> ConfigException: Value must be no more than 2147483647\n\n// after\nprops.put(ConsumerConfig.FETCH_MAX_BYTES_CONFIG,\n         50 * 1024 * 1024); // 50 MiB","handlingStrategy":"validation","validationCode":"if (value instanceof Number) {\n    double n = ((Number) value).doubleValue();\n    if (max != null && n > max.doubleValue()) {\n        throw new IllegalArgumentException(\"config '\" + key + \"' must be <= \" + max);\n    }\n}","typeGuard":"public static boolean meetsMax(Number value, Number max) {\n    return value != null && max != null && value.doubleValue() <= max.doubleValue();\n}","tryCatchPattern":"try {\n    configDef.parse(configs);\n} catch (ConfigException e) {\n    if (e.getMessage().startsWith(\"Value must be no more than\")) {\n        // clamp down to `max` (or surface to the operator) and retry\n    } else throw e;\n}","preventionTips":["Document the inclusive upper bound for each ranged numeric key.","Reject astronomically large 'safety' values (e.g. Long.MAX_VALUE for timeouts) at the input boundary if they exceed the documented max."],"tags":["config","validation","out-of-range","client"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}