apache/pulsar · error · ParameterException
Need to specify either --enable or --disable
Error message
Need to specify either --enable or --disable
What it means
Thrown by the set-delayed-delivery command when the --enable and --disable flags end up equal (both false or both true), so the desired policy state is ambiguous. The command requires exactly one of the two flags to be set to set the delayed delivery policy's active flag.
Source
Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java:792
+ "delayed delivery messages, affecting the accuracy of the delivery time compared to "
+ "the scheduled time. (eg: 1s, 10s, 1m, 5h, 3d)",
converter = TimeUnitToMillisConverter.class)
private Long delayedDeliveryTimeInMills = 1000L;
@Option(names = { "--global", "-g" }, description = "Whether to set this policy globally. "
+ "If set to true, the policy will be replicate to other clusters asynchronously")
private boolean isGlobal;
@Option(names = { "--maxDelay", "-md" },
description = "The max allowed delay for delayed delivery. (eg: 1s, 10s, 1m, 5h, 3d)",
converter = TimeUnitToMillisConverter.class)
private Long delayedDeliveryMaxDelayInMillis = 0L;
@Override
void run() throws PulsarAdminException {
String topic = validateTopicName(topicName);
if (enable == disable) {
throw new ParameterException("Need to specify either --enable or --disable");
}
getTopicPolicies(isGlobal).setDelayedDeliveryPolicy(topic, DelayedDeliveryPolicies.builder()
.tickTime(delayedDeliveryTimeInMills)
.active(enable)
.maxDeliveryDelayInMillis(delayedDeliveryMaxDelayInMillis)
.build());
}
}
@Command(description = "Remove the delayed delivery policy on a topic")
private class RemoveDelayedDelivery extends CliCommand {
@Parameters(description = "persistent://tenant/namespace/topic", arity = "1")
private String topicName;
@Option(names = { "--global", "-g" }, description = "Whether to remove this policy globally. "
+ "If set to true, the policy will be replicate to other clusters asynchronously")
private boolean isGlobal;View on GitHub (pinned to 820761864e)
Solutions
- Add exactly one of --enable or --disable to the command
- If both are passed, remove one so they differ
- Fix the script so the boolean maps to exactly one flag
Example fix
// before pulsar-admin topics set-delayed-delivery --tick-time 1000 -t my-topic // after pulsar-admin topics set-delayed-delivery --enable --tick-time 1000 -t my-topic
Defensive patterns
Strategy: validation
Validate before calling
if (enable == disable) {
throw new IllegalArgumentException("Pass exactly one of --enable or --disable");
} Try / catch
try {
admin.topicPolicies().setDelayedDeliveryPolicy(topic, policy);
} catch (ParameterException e) {
System.err.println("Specify exactly one of --enable/--disable");
} Prevention
- Always pair set-delayed-delivery with exactly one flag
- In scripts, map booleans to one flag via if/else, not parameter expansion
- Double-check copy-pasted commands for duplicated flags
When it happens
Trigger: Running `pulsar-admin topics set-delayed-delivery` with neither --enable nor --disable, or (in some flag-parsing setups) both flags provided so they cancel out to equal values.
Common situations: Omitting the flag entirely, scripting where a boolean variable is neither converted to --enable nor --disable, or accidentally passing the flag twice (e.g. --enable --disable).
Related errors
- Illegal subscription type %s. Possible values: %s.
- Invalid interval '%d'.
- Invalid retention policy type '%s'. Valid options are: %s
- Need to provide a persistent topic name
- Need to provide a non-persistent topic name
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/1316b5ff156bd08b.
Report an issue: GitHub.