{"record":{"id":"0cde8733e7fe4e2a","repo":"apache/pulsar","slug":"can-t-create-topic-topicname-with-partition","errorCode":null,"errorMessage":"Can't create topic ${topicName} with \"-partition-\" followed by a number smaller than number of partition of partitioned topic ${partitionTopicName.getLocalName()}","messagePattern":"Can't create topic (.+?) with \"-partition-\" followed by a number smaller than number of partition of partitioned topic (.+?)","errorType":"http","errorClass":"RestException","httpStatus":412,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java","lineNumber":4836,"sourceCode":"        CompletableFuture<Void> ret = CompletableFuture.completedFuture(null);\n        if (topicName.contains(PARTITIONED_TOPIC_SUFFIX)) {\n            try {\n                // First check if what's after suffix \"-partition-\" is number or not, if not number then can create.\n                int partitionIndex = topicName.indexOf(PARTITIONED_TOPIC_SUFFIX);\n                long suffix = Long.parseLong(topicName.substring(partitionIndex\n                        + PARTITIONED_TOPIC_SUFFIX.length()));\n                TopicName partitionTopicName = TopicName.get(domain(),\n                        namespaceName, topicName.substring(0, partitionIndex));\n                ret = getPartitionedTopicMetadataAsync(partitionTopicName, false, false)\n                        .thenAccept(metadata -> {\n                            // Partition topic index is 0 to (number of partition - 1)\n                            if (metadata.partitions > 0 && suffix >= (long) metadata.partitions) {\n                                log.warn()\n                                        .attr(\"topic\", topicName)\n                                        .attr(\"partitionedTopic\", partitionTopicName.getLocalName())\n                                        .log(\"Can't create topic with -partition- followed by\"\n                                                + \" a number smaller than partition count\");\n                                throw new RestException(Status.PRECONDITION_FAILED,\n                                        \"Can't create topic \" + topicName + \" with \\\"-partition-\\\" followed by\"\n                                                + \" a number smaller than number of partition of partitioned topic \"\n                                                + partitionTopicName.getLocalName());\n                            } else if (metadata.partitions == 0) {\n                                log.warn()\n                                        .attr(\"topic\", topicName)\n                                        .attr(\"partitionedTopic\", partitionTopicName.getLocalName())\n                                        .log(\"Can't create topic with -partition- followed by\"\n                                                + \" numeric value without a partitioned topic\");\n                                throw new RestException(Status.PRECONDITION_FAILED,\n                                        \"Can't create topic \" + topicName + \" with \\\"-partition-\\\" followed by\"\n                                                + \" numeric value if there isn't a partitioned topic \"\n                                                + partitionTopicName.getLocalName() + \" created.\");\n                            }\n                            // If there is a  partitioned topic with the same name and numeric suffix is smaller\n                            // than the number of partition for that partitioned topic, validation will pass.\n                        });\n            } catch (NumberFormatException e) {","sourceCodeStart":4818,"sourceCodeEnd":4854,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L4818-L4854","documentation":"validateGlobalNamespaceName-style guard in topic-name validation: a topic whose name embeds '-partition-<n>' would collide with an existing partitioned topic's partition index space, so creation is refused with 409.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:4836 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a topic name without a '-partition-' + number suffix","If a real partition is intended, create it via the partitioned topic API"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}