apache/pulsar · error · IllegalArgumentException
The value of ${paramName} can't be empty
Error message
The value of ${paramName} can't be empty What it means
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.
Source
Thrown at pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/ValueValidationUtil.java:47
throw new IllegalArgumentException(paramName + " cannot be bigger than <" + maxValue + ">!");
}
}
public static void positiveCheck(String paramName, long value) {
if (value <= 0) {
throw new IllegalArgumentException(paramName + " cannot be less than or equal to <0>!");
}
}
public static void positiveCheck(String paramName, int value) {
if (value <= 0) {
throw new IllegalArgumentException(paramName + " cannot be less than or equal to <0>!");
}
}
public static void emptyCheck(String paramName, String value) {
if (StringUtils.isEmpty(value)) {
throw new IllegalArgumentException("The value of " + paramName + " can't be empty");
}
}
public static void minValueCheck(String name, Long value, long min) {
if (value < min) {
throw new IllegalArgumentException(name + " cannot be less than <" + min + ">!");
}
}
}
View on GitHub (pinned to 820761864e)
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.
Example fix
// before (TOPIC unset)
pulsar-admin topics delete "$TOPIC"
// after
echo "TOPIC=${TOPIC:?must be set}"
pulsar-admin topics delete "$TOPIC" Defensive patterns
Strategy: validation
Validate before calling
public static String requireNonEmpty(String name, String value) {
if (value == null || value.trim().isEmpty()) {
throw new IllegalArgumentException(name + " is required and cannot be empty");
}
return value.trim();
}
// shell: : "${TOPIC:?TOPIC is required}" before invoking the CLI Try / catch
try {
tool.run(args);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().contains("can't be empty")) {
System.err.println("Missing required argument: " + e.getMessage());
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- ${paramName} cannot be bigger than <${maxValue}>!
- ${paramName} cannot be less than or equal to <0>!
- ${name} cannot be less than <${min}>!
- Number of messages should be zero or positive.
- byte string cannot be empty
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/fcb74ff51c6a3e0d.
Report an issue: GitHub.