apache/pulsar · error · ParameterException
delete mode can only be set to delete_when_no_subscriptions
Error message
delete mode can only be set to delete_when_no_subscriptions or delete_when_subscriptions_caught_up
What it means
Thrown by 'set-inactive-topic-policies' when the value passed to the inactive-topic-delete-mode flag is not a valid InactiveTopicDeleteMode enum constant. The code does InactiveTopicDeleteMode.valueOf(...) and converts the resulting IllegalArgumentException into this ParameterException, listing the only accepted values: delete_when_no_subscriptions or delete_when_subscriptions_caught_up. It is a client-side value validation before any admin call.
Source
Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java:1601
converter = TimeUnitToSecondsConverter.class)
private Long maxInactiveDurationInSeconds;
@Option(names = { "--delete-mode", "-m" }, description = "Mode of delete inactive topic, Valid options are: "
+ "[delete_when_no_subscriptions, delete_when_subscriptions_caught_up]", required = true)
private String inactiveTopicDeleteMode;
@Override
void run() throws PulsarAdminException {
String namespace = validateNamespace(namespaceName);
if (enableDeleteWhileInactive == disableDeleteWhileInactive) {
throw new ParameterException("Need to specify either enable-delete-while-inactive or "
+ "disable-delete-while-inactive");
}
InactiveTopicDeleteMode deleteMode = null;
try {
deleteMode = InactiveTopicDeleteMode.valueOf(inactiveTopicDeleteMode);
} catch (IllegalArgumentException e) {
throw new ParameterException("delete mode can only be set to delete_when_no_subscriptions or "
+ "delete_when_subscriptions_caught_up");
}
getAdmin().namespaces().setInactiveTopicPolicies(namespace, new InactiveTopicPolicies(deleteMode,
maxInactiveDurationInSeconds.intValue(), enableDeleteWhileInactive));
}
}
@Command(description = "Set the delayed delivery policy on a namespace")
private class SetDelayedDelivery extends CliCommand {
@Parameters(description = "tenant/namespace", arity = "1")
private String namespaceName;
@Option(names = { "--enable", "-e" }, description = "Enable delayed delivery messages")
private boolean enable = false;
@Option(names = { "--disable", "-d" }, description = "Disable delayed delivery messages")
private boolean disable = false;
View on GitHub (pinned to 820761864e)
Solutions
- Use exactly one of the accepted values: delete_when_no_subscriptions or delete_when_subscriptions_caught_up (all lowercase).
- Check the enum spelling with the values shown in this message or 'pulsar-admin namespaces set-inactive-topic-policies --help'.
- Fix shell variables so an empty/undefined value is not expanded into the flag.
Example fix
// before pulsar-admin namespaces set-inactive-topic-policies public/default --enable-delete-while-inactive --deleteWhenNoSubscriptions --max-inactive-duration 30 // after pulsar-admin namespaces set-inactive-topic-policies public/default --enable-delete-while-inactive --delete_when_no_subscriptions --max-inactive-duration 30
Defensive patterns
Strategy: validation
Validate before calling
MODE="$1" case "$MODE" in delete_when_no_subscriptions|delete_when_subscriptions_caught_up) ;; *) echo "invalid delete mode: $MODE"; exit 1;; esac
Prevention
- Use exact lowercase enum values: delete_when_no_subscriptions or delete_when_subscriptions_caught_up.
- Never camelCase or abbreviate the mode.
- Source values from the error's possible-values list, not memory.
When it happens
Trigger: Passing an unknown/misspelled delete mode string (e.g. 'deleteWhenNoSubscriptions', 'delete_when_subscription_caught_up', 'none') to the delete-mode flag of set-inactive-topic-policies.
Common situations: Case mismatch (camelCase vs SCREAMING_SNAKE); hand-editing scripts with a guessed enum name; docs/versions drift where an old or hypothetical mode value is used.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Either --compatibility or --disabled must be specified
- Illegal schema compatibility strategy %s. Possible values: %
- Need to provide a persistent topic name
- Need to provide a non-persistent topic name
- Invalid message id (must be in format: ledgerId:entryId) val
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/4c15503445e87113.
Report an issue: GitHub.