{"id":"d3b0e18952a02646","repo":"apache/kafka","slug":"value-must-be-at-least-min","errorCode":null,"errorMessage":"Value must be at least min","messagePattern":"Value must be at least min","errorType":"validation","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java","lineNumber":1013,"sourceCode":"         * @param min The minimum acceptable value\n         */\n        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","sourceCodeStart":995,"sourceCodeEnd":1031,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java#L995-L1031","documentation":"Thrown by Range.ensureValid when a numeric value is below the lower bound declared via Range.atLeast(min) or Range.between(min,max). This enforces a minimum acceptable value for bounded numeric configs (e.g. reconnect.backoff.ms >= 0, request.timeout.ms >= 1, num.io.threads >= 1, fetch.max.bytes >= 1). The bound value is appended to the message so the developer knows the threshold.","triggerScenarios":"Calling ConfigDef.validate or constructing a client with a numeric config set below the documented minimum — e.g. retries=-1, request.timeout.ms=0, fetch.min.bytes=-5, num.network.threads=0, max.poll.records=0.","commonSituations":"Operator tuning a broker/client below the safe minimum to disable a feature (e.g. setting a timeout to 0 expecting 'disabled'); negative values used as 'infinite' sentinels; config templating that subtracts from a base; copy-paste from a stale doc with different bounds; migration between Kafka versions where the lower bound was tightened.","solutions":["Set the value to at least the documented minimum (shown in the message).","If you intended to disable the behavior, find the documented 'disable' value (often 0 or Long.MAX_VALUE) rather than a negative number.","Check the Kafka docs for the specific version — bounds can change across releases.","Re-validate the full ConfigDef via AdminClient.describeConfigs or ConfigDef.validate to surface any other out-of-range keys at once."],"exampleFix":"// before\nprops.put(ProducerConfig.RETRIES_CONFIG, -1);\n// -> ConfigException: Value must be at least 0\n\n// after\nprops.put(ProducerConfig.RETRIES_CONFIG, Integer.MAX_VALUE); // or 0","handlingStrategy":"validation","validationCode":"if (value instanceof Number) {\n    double n = ((Number) value).doubleValue();\n    if (min != null && n < min.doubleValue()) {\n        throw new IllegalArgumentException(\"config '\" + key + \"' must be >= \" + min);\n    }\n}","typeGuard":"public static boolean meetsMin(Number value, Number min) {\n    return value != null && min != null && value.doubleValue() >= min.doubleValue();\n}","tryCatchPattern":"try {\n    configDef.parse(configs);\n} catch (ConfigException e) {\n    if (e.getMessage().startsWith(\"Value must be at least\")) {\n        // clamp up to `min` (or surface to the operator) and retry\n    } else throw e;\n}","preventionTips":["Document the inclusive lower bound for each ranged numeric key in your config schema.","Clamp or reject out-of-range values at the input boundary, before they reach Kafka client construction."],"tags":["config","validation","out-of-range","client"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}