apache/pulsar · error · ParameterException
Must specify type of topic to be created. Possible values: (
Error message
Must specify type of topic to be created. Possible values: (partitioned, non-partitioned)
What it means
Thrown when --enable is set but the --type value is not one of the accepted TopicType names (partitioned, non-partitioned). TopicType.isValidTopicType(type) fails, so the CLI rejects the auto-topic-creation override rather than sending an invalid type to the broker.
Source
Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java:657
@Option(names = { "--type", "-t" }, description = "Type of topic to be auto-created. "
+ "Possible values: (partitioned, non-partitioned). Default value: non-partitioned")
private String type = "non-partitioned";
@Option(names = { "--num-partitions", "-n" }, description = "Default number of partitions of topic to "
+ "be auto-created, applicable to partitioned topics only", required = false)
private Integer defaultNumPartitions = null;
@Override
void run() throws PulsarAdminException {
String namespace = validateNamespace(namespaceName);
type = type.toLowerCase().trim();
if (enable == disable) {
throw new ParameterException("Need to specify either --enable or --disable");
}
if (enable) {
if (!TopicType.isValidTopicType(type)) {
throw new ParameterException("Must specify type of topic to be created. "
+ "Possible values: (partitioned, non-partitioned)");
}
if (TopicType.PARTITIONED.toString().equals(type)
&& (defaultNumPartitions == null || defaultNumPartitions <= 0)) {
throw new ParameterException("Must specify num-partitions or num-partitions > 0 "
+ "for partitioned topic type.");
}
}
getAdmin().namespaces().setAutoTopicCreation(namespace,
AutoTopicCreationOverride.builder()
.allowAutoTopicCreation(enable)
.topicType(type)
.defaultNumPartitions(defaultNumPartitions)
.build());
}
}
View on GitHub (pinned to 820761864e)
Solutions
- Pass --type partitioned or --type non-partitioned (lowercase) whenever --enable is used
- Fix spelling/casing of the type value
- If disabling auto topic creation, --type is not needed; only pass it when enabling
- Set --default-num-partitions too when type is partitioned (see error 869)
Example fix
// before pulsar-admin namespaces set-auto-topic-creation t/ns --enable --type Partitioned // after pulsar-admin namespaces set-auto-topic-creation t/ns --enable --type partitioned --default-num-partitions 4
Defensive patterns
Strategy: validation
Validate before calling
if [ "$ENABLE" = true ]; then case "$TYPE" in partitioned|non-partitioned) ;; *) echo "--type must be partitioned or non-partitioned"; exit 1;; esac fi
Type guard
// Java
boolean isValidTopicType(String t) {
return "partitioned".equals(t) || "non-partitioned".equals(t);
} Try / catch
try { ... } catch (ParameterException e) { /* bad topic type: use partitioned|non-partitioned */ } Prevention
- When enabling, always pass --type with lowercase partitioned or non-partitioned
- Do not use persistent/non-persistent as values — those are topic domains
- Only pass --type when --enable is used
When it happens
Trigger: Running `set-auto-topic-creation --enable` with --type omitted (null/empty), misspelled ('partitoned'), wrong case ('Partitioned'), or a value like 'schema-ful' that is not a TopicType.
Common situations: Forgetting --type because it feels implied by --enable; using topic-domain names (persistent / non-persistent) instead of TopicType names; case issues from variable interpolation.
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
- Must specify num-partitions or num-partitions > 0 for partit
- 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
- unable to parse namespaces parameter list:
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/f4caf523e327551a.
Report an issue: GitHub.