{"record":{"id":"42a978ea10976b0e","repo":"apache/pulsar","slug":"this-topic-already-exists-42a978","errorCode":null,"errorMessage":"This topic already exists","messagePattern":"This topic already exists","errorType":"http","errorClass":"RestException","httpStatus":409,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java","lineNumber":351,"sourceCode":"                    resumeAsyncResponseExceptionally(asyncResponse, realCause);\n                    return null;\n                });\n    }\n\n    protected CompletableFuture<Void> internalCreateNonPartitionedTopicAsync(boolean authoritative,\n                                                     Map<String, String> properties) {\n        return validateNonPartitionTopicNameAsync(topicName.getLocalName())\n                .thenCompose(__ -> validateGlobalNamespaceOwnershipAsync(namespaceName))\n                .thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative))\n           .thenCompose(__ -> validateNamespaceOperationAsync(topicName.getNamespaceObject(),\n                   NamespaceOperation.CREATE_TOPIC))\n           .thenCompose(__ -> getPartitionedTopicMetadataAsync(topicName, false, false))\n           .thenAccept(partitionMetadata -> {\n               if (partitionMetadata.partitions > 0) {\n                   log.warn()\n                           .attr(\"exists\", topicName)\n                           .log(\"Partitioned topic with the same name already exists\");\n                   throw new RestException(Status.CONFLICT, \"This topic already exists\");\n               }\n           })\n           .thenCompose(__ -> pulsar().getBrokerService().getTopicIfExists(topicName.toString()))\n           .thenCompose(existedTopic -> {\n               if (existedTopic.isPresent()) {\n                   log.warn().attr(\"topic\", topicName).log(\"Topic already exists\");\n                   throw new RestException(Status.CONFLICT, \"This topic already exists\");\n               }\n               return pulsar().getBrokerService().getTopic(topicName.toString(), true, properties);\n           })\n           .thenAccept(__ -> log.info()\n                   .attr(\"topic\", topicName)\n                   .log(\"Successfully created non-partitioned topic\"));\n    }\n\n    /**\n     * It updates number of partitions of an existing partitioned topic. It requires partitioned-topic to\n     * already exist and number of new partitions must be greater than existing number of partitions. Decrementing","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L333-L369","documentation":"internalCreateNonPartitionedTopicAsync detected that the topic being created already exists on the broker, so creation is refused with 409 Conflict rather than overwriting the existing topic's metadata.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:351 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the existing topic instead of creating it","Pass the appropriate create-or-continue semantics if supported by the client"],"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"}