{"record":{"id":"87f63ff5d6f0ac65","repo":"apache/pulsar","slug":"can-t-create-topic-topicname-with-partition-87f63f","errorCode":null,"errorMessage":"Can't create topic ${topicName} with \"-partition-\" followed by numeric value if there isn't a partitioned topic ${partitionTopicName.getLocalName()} created.","messagePattern":"Can't create topic (.+?) with \"-partition-\" followed by numeric value if there isn't a partitioned topic (.+?) created\\.","errorType":"http","errorClass":"RestException","httpStatus":412,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java","lineNumber":4846,"sourceCode":"                        .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) {\n                // Do nothing, if value after partition suffix is not pure numeric value,\n                // as it can't conflict if user want to create partitioned topic with same\n                // topic name prefix in the future.\n            }\n        }\n        return ret;\n    }\n\n    protected void internalGetLastMessageId(AsyncResponse asyncResponse, boolean authoritative) {\n        validateTopicOperationAsync(topicName, TopicOperation.PEEK_MESSAGES)","sourceCodeStart":4828,"sourceCodeEnd":4864,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L4828-L4864","documentation":"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.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:4846 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the topic to avoid the reserved -partition-N pattern","Create the partitioned topic first if partitions are genuinely wanted"],"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"}