{"record":{"id":"fcb74ff51c6a3e0d","repo":"apache/pulsar","slug":"the-value-of-paramname-can-t-be-empty","errorCode":null,"errorMessage":"The value of ${paramName} can't be empty","messagePattern":"The value of (.+?) can't be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/ValueValidationUtil.java","lineNumber":47,"sourceCode":"            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 + \">!\");\n        }\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":57,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/ValueValidationUtil.java#L29-L57","documentation":"ValueValidationUtil.emptyCheck rejects null/empty string CLI parameters with 'The value of <param> can't be empty'. It guards mandatory textual options (topic names, cluster names, subjects) so the tool fails fast at argument validation instead of sending a degenerate request to the broker.","triggerScenarios":"Calling emptyCheck(paramName, value) where value is null or StringUtils.isEmpty(value) is true — e.g. an unset shell variable producing an empty --topic argument.","commonSituations":"Shell scripts with unset/empty variables interpolated as empty flags; quoting mistakes dropping the argument; whitespace-only strings that read as non-empty to the user.","solutions":["Supply the required non-empty value for the named parameter.","In scripts, guard with : \"${TOPIC:?TOPIC is required}\" or [ -n \"$TOPIC\" ] before invoking the CLI.","Check quoting so the value isn't swallowed as an empty argument.","Trim the value — whitespace-only strings also fail the emptiness check."],"exampleFix":"// before (TOPIC unset)\npulsar-admin topics delete \"$TOPIC\"\n// after\necho \"TOPIC=${TOPIC:?must be set}\"\npulsar-admin topics delete \"$TOPIC\"","handlingStrategy":"validation","validationCode":"public static String requireNonEmpty(String name, String value) {\n    if (value == null || value.trim().isEmpty()) {\n        throw new IllegalArgumentException(name + \" is required and cannot be empty\");\n    }\n    return value.trim();\n}\n// shell: : \"${TOPIC:?TOPIC is required}\" before invoking the CLI","typeGuard":null,"tryCatchPattern":"try {\n    tool.run(args);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"can't be empty\")) {\n        System.err.println(\"Missing required argument: \" + e.getMessage());\n    } else throw e;\n}","preventionTips":["Use ${VAR:?msg} guards in shell scripts for mandatory variables.","Check quoting so values aren't dropped as empty arguments.","Trim whitespace-only inputs — they fail the empty check too.","Document required flags in wrapper script usage messages."],"tags":["cli","validation","argument","empty"],"backgroundTag":"missing-required-argument","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}