apache/pulsar · error · RestException
Can't create topic ${topicName} with "-partition-" followed
Error message
Can't create topic ${topicName} with "-partition-" followed by numeric value if there isn't a partitioned topic ${partitionTopicName.getLocalName()} created. What it means
Topic-name validation guard: the requested name contains the '-partition-' suffix followed by a number, but no corresponding partitioned topic exists; the broker refuses to implicitly create a partition name that would shadow a nonexistent partitioned topic.
Source
Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:4846
.thenAccept(metadata -> {
// Partition topic index is 0 to (number of partition - 1)
if (metadata.partitions > 0 && suffix >= (long) metadata.partitions) {
log.warn()
.attr("topic", topicName)
.attr("partitionedTopic", partitionTopicName.getLocalName())
.log("Can't create topic with -partition- followed by"
+ " a number smaller than partition count");
throw new RestException(Status.PRECONDITION_FAILED,
"Can't create topic " + topicName + " with \"-partition-\" followed by"
+ " a number smaller than number of partition of partitioned topic "
+ partitionTopicName.getLocalName());
} else if (metadata.partitions == 0) {
log.warn()
.attr("topic", topicName)
.attr("partitionedTopic", partitionTopicName.getLocalName())
.log("Can't create topic with -partition- followed by"
+ " numeric value without a partitioned topic");
throw new RestException(Status.PRECONDITION_FAILED,
"Can't create topic " + topicName + " with \"-partition-\" followed by"
+ " numeric value if there isn't a partitioned topic "
+ partitionTopicName.getLocalName() + " created.");
}
// If there is a partitioned topic with the same name and numeric suffix is smaller
// than the number of partition for that partitioned topic, validation will pass.
});
} catch (NumberFormatException e) {
// Do nothing, if value after partition suffix is not pure numeric value,
// as it can't conflict if user want to create partitioned topic with same
// topic name prefix in the future.
}
}
return ret;
}
protected void internalGetLastMessageId(AsyncResponse asyncResponse, boolean authoritative) {
validateTopicOperationAsync(topicName, TopicOperation.PEEK_MESSAGES)View on GitHub (pinned to 820761864e)
Solutions
- Rename the topic to avoid the reserved -partition-N pattern
- Create the partitioned topic first if partitions are genuinely wanted
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:4846 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/87f63ff5d6f0ac65.
Report an issue: GitHub.