apache/pulsar · error · ParameterException
Illegal subscription type %s. Possible values: %s.
Error message
Illegal subscription type %s. Possible values: %s.
What it means
Thrown when a --sub-type value passed to the set-subscription-types-enabled command cannot be resolved to a pulsar.common.util.SubscriptionType enum constant via valueOf. The message lists all legal values so the caller can correct the input.
Source
Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java:353
@Command(description = "Set subscription types enabled for a namespace")
private class SetSubscriptionTypesEnabled extends CliCommand {
@Parameters(description = "tenant/namespace", arity = "1")
private String namespaceName;
@Option(names = {"--types", "-t"}, description = "Subscription types enabled list (comma separated values)."
+ " Possible values: (Exclusive, Shared, Failover, Key_Shared).", required = true, split = ",")
private List<String> subTypes;
@Override
void run() throws PulsarAdminException {
String namespace = validateNamespace(namespaceName);
Set<SubscriptionType> types = new HashSet<>();
subTypes.forEach(s -> {
SubscriptionType subType;
try {
subType = SubscriptionType.valueOf(s);
} catch (IllegalArgumentException exception) {
throw new ParameterException(String.format("Illegal subscription type %s. Possible values: %s.", s,
Arrays.toString(SubscriptionType.values())));
}
types.add(subType);
});
getAdmin().namespaces().setSubscriptionTypesEnabled(namespace, types);
}
}
@Command(description = "Get subscription types enabled for a namespace")
private class GetSubscriptionTypesEnabled extends CliCommand {
@Parameters(description = "tenant/namespace", arity = "1")
private String namespaceName;
@Override
void run() throws PulsarAdminException {
String namespace = validateNamespace(namespaceName);
print(getAdmin().namespaces().getSubscriptionTypesEnabled(namespace));
}View on GitHub (pinned to 820761864e)
Solutions
- Use exact enum names: SubscriptionType.values() shows them, e.g. --sub-type Shared --sub-type Failover --sub-type Key_Shared
- Match case exactly (valueOf is case-sensitive)
- Repeat the --sub-type flag once per type instead of comma-joining
- Check SubscriptionType constants for your Pulsar version (Key_Shared requires a recent version)
Example fix
// before pulsar-admin namespaces set-subscription-types-enabled t/ns --sub-type shared // after pulsar-admin namespaces set-subscription-types-enabled t/ns --sub-type Shared --sub-type Failover
Defensive patterns
Strategy: validation
Validate before calling
VALID='Exclusive Shared Failover Key_Shared'
for t in $SUB_TYPES; do [[ " $VALID " == *" $t "* ]] || { echo "illegal subscription type: $t"; exit 1; }; done Type guard
// Java
boolean isValidSubType(String s) {
for (SubscriptionType t : SubscriptionType.values()) {
if (t.name().equals(s)) return true;
}
return false;
} Try / catch
try { ... } catch (ParameterException e) { /* bad enum name: use exact SubscriptionType names */ } Prevention
- Use exact case-sensitive enum names (Shared, not shared)
- Repeat --sub-type per value instead of comma-joining
- Confirm Key_Shared exists in your Pulsar version
When it happens
Trigger: Running `pulsar-admin namespaces set-subscription-types-enabled <ns> --sub-type` with an invalid name such as 'Exclusive', 'shared' in wrong case, or a typo like 'Failovered'. Only enum constants of SubscriptionType (e.g. Exclusive, Shared, Failover, Key_Shared) are accepted.
Common situations: Lowercasing enum names in scripts ('shared' instead of 'Shared'); using documentation terms like 'non-durable' which are not SubscriptionType constants; version drift where a type like Key_Shared doesn't exist in older clients; multiple values separated incorrectly.
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
- Invalid backlog quota type '%s'. Valid options are: %s
- delete mode can only be set to delete_when_no_subscriptions
- --offloadedReadPriority parameter must be one of ${validValu
- Illegal subscription type %s. Possible values: %s.
- Need to provide a persistent topic name
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/0330a6a6b151b7ba.
Report an issue: GitHub.