{"record":{"id":"ea1d3a75b766e5be","repo":"apache/pulsar","slug":"paramname-cannot-be-less-than-or-equal-to-0","errorCode":null,"errorMessage":"${paramName} cannot be less than or equal to <0>!","messagePattern":"(.+?) cannot be less than or equal to <0>!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/ValueValidationUtil.java","lineNumber":35,"sourceCode":" * 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\");\n        }\n    }\n\n    public static void minValueCheck(String name, Long value, long min) {\n        if (value < min) {\n            throw new IllegalArgumentException(name + \" cannot be less than <\" + min + \">!\");","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/ValueValidationUtil.java#L17-L53","documentation":"ValueValidationUtil.positiveCheck(long) rejects non-positive numeric CLI parameters: any value <= 0 throws IllegalArgumentException with '<param> cannot be less than or equal to <0>!'. Parameters guarded here are expected to be strictly positive (counts, sizes, timeouts), so zero and negatives are both invalid.","triggerScenarios":"Calling positiveCheck(paramName, value) with a long value of 0 or negative — e.g. --rate -1, --messages 0 on a producer/consumer CLI tool.","commonSituations":"Uninitialized variables in shell scripts defaulting to 0; arithmetic producing negative values; user assuming 0 means 'unlimited' when the tool requires a positive number.","solutions":["Pass a strictly positive value (> 0) for the named parameter.","If 0 was intended as 'unlimited/default', omit the flag or use the tool's documented sentinel instead of 0.","Fix the calling script to clamp values: [ \"$v\" -gt 0 ] || exit before invoking the tool.","Check sign errors from computed expressions (e.g. end - start) feeding the argument."],"exampleFix":"// before\npulsar-client produce --num-messages 0 ...\n// after\npulsar-client produce --num-messages 10 ...","handlingStrategy":"validation","validationCode":"public static long requirePositive(String name, long value) {\n    if (value <= 0) throw new IllegalArgumentException(name + \" must be > 0, got \" + value);\n    return value;\n}\n// call before the CLI tool: requirePositive(\"num-messages\", numMessages);","typeGuard":null,"tryCatchPattern":"try {\n    tool.run(args);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"cannot be less than or equal to <0>\")) {\n        System.err.println(\"Value must be positive: \" + e.getMessage());\n    } else throw e;\n}","preventionTips":["Initialize shell variables with defaults so they are never 0/negative.","Remember 0 is invalid here — don't use it to mean 'unlimited'.","Validate computed expressions for sign before passing them.","Add argument checks at the top of wrapper scripts."],"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"}