{"record":{"id":"34af5c1b8700c10a","repo":"apache/pulsar","slug":"paramname-cannot-be-bigger-than-maxvalue","errorCode":null,"errorMessage":"${paramName} cannot be bigger than <${maxValue}>!","messagePattern":"(.+?) cannot be bigger than <(.+?)>!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/ValueValidationUtil.java","lineNumber":29,"sourceCode":" *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\npackage org.apache.pulsar.cli;\n\nimport lombok.experimental.UtilityClass;\nimport org.apache.commons.lang3.StringUtils;\n\n@UtilityClass\npublic class ValueValidationUtil {\n\n    public static void maxValueCheck(String paramName, long value, long maxValue) {\n        if (value > maxValue) {\n            throw new IllegalArgumentException(paramName + \" cannot be bigger than <\" + maxValue + \">!\");\n        }\n    }\n\n    public static void positiveCheck(String paramName, long value) {\n        if (value <= 0) {\n            throw new IllegalArgumentException(paramName + \" cannot be less than or equal to <0>!\");\n        }\n    }\n\n    public static void positiveCheck(String paramName, int value) {\n        if (value <= 0) {\n            throw new IllegalArgumentException(paramName + \" cannot be less than or equal to <0>!\");\n        }\n    }\n\n    public static void emptyCheck(String paramName, String value) {\n        if (StringUtils.isEmpty(value)) {\n            throw new IllegalArgumentException(\"The value of \" + paramName + \" can't be empty\");","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/ValueValidationUtil.java#L11-L47","documentation":"ValueValidationUtil.maxValueCheck is a CLI argument guard in pulsar-cli-utils: it throws IllegalArgumentException when a numeric parameter exceeds an allowed maximum. It is used by Pulsar admin/client tooling to reject out-of-range option values (e.g. retention size, batch sizes) before they reach the server. The message embeds the parameter name and the max bound.","triggerScenarios":"Any CLI/admin call site invoking ValueValidationUtil.maxValueCheck(paramName, value, maxValue) with value > maxValue — e.g. passing --max-messages 100000 when the tool caps it lower.","commonSituations":"Scripting Pulsar CLI tools with variables that exceed documented limits; typos producing absurd values (extra zero); copy-pasted commands from docs tuned for larger clusters; unit confusion (bytes vs MB).","solutions":["Lower the argument value to <= the reported maxValue in the message.","Check unit scaling: if the tool expects bytes and you passed a page/kilobyte figure, convert before invoking.","Fix the calling script so variables are clamped/validated before building the command line.","If the max is legitimately too low for your use case, check documentation/upstream for the current limit rather than patching the util."],"exampleFix":"// before\npulsar-admin topics set-retention --size 100G ...\n// after (if the limit is 40GB)\npulsar-admin topics set-retention --size 40G ...","handlingStrategy":"validation","validationCode":"public static void requireMax(String name, long value, long max) {\n    if (value > max) {\n        throw new IllegalArgumentException(name + \"=\" + value + \" exceeds max \" + max);\n    }\n}\n// call before the CLI tool: requireMax(\"size\", parsedSize, 40L * 1024 * 1024 * 1024);","typeGuard":null,"tryCatchPattern":"try {\n    tool.run(args);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"cannot be bigger than\")) {\n        System.err.println(\"Reduce the value: \" + e.getMessage());\n    } else throw e;\n}","preventionTips":["Clamp user-supplied numbers to documented limits in wrapper scripts.","Watch for typos and extra zeros; sanity-check magnitudes before submission.","Be explicit about units (bytes vs MB vs GB) when computing the value.","Prefer reading limits from tool docs rather than trial and error."],"tags":["cli","validation","argument","pulsar"],"backgroundTag":"argument-out-of-range","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}