{"record":{"id":"ec309bb4fa92d22b","repo":"apache/pulsar","slug":"getmessageidbyindex-is-not-allowed-on-partitioned","errorCode":null,"errorMessage":"GetMessageIDByIndex is not allowed on partitioned-topic","messagePattern":"GetMessageIDByIndex is not allowed on partitioned-topic","errorType":"http","errorClass":"RestException","httpStatus":405,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java","lineNumber":5732,"sourceCode":"        if (index == null || index < 0) {\n            return FutureUtil.failedFuture(new RestException(Status.NOT_FOUND,\n                    \"Invalid message index: \" + index));\n        }\n        int partitionIndex = topicName.getPartitionIndex();\n        return validateTopicOperationAsync(topicName, TopicOperation.PEEK_MESSAGES)\n                .thenCompose(__ -> validateGlobalNamespaceOwnershipAsync(namespaceName))\n                .thenCompose(__ -> {\n                    if (topicName.isPartitioned()) {\n                        return CompletableFuture.completedFuture(null);\n                    } else {\n                        return getPartitionedTopicMetadataAsync(topicName, authoritative, false)\n                                .thenAccept(topicMetadata -> {\n                                    if (topicMetadata.partitions > 0) {\n                                        log.warn()\n                                                .attr(\"topic\", topicName)\n                                                .log(\"Not supported getMessageIdByIndex operation on\"\n                                                        + \" partitioned-topic\");\n                                        throw new RestException(Status.METHOD_NOT_ALLOWED,\n                                                \"GetMessageIDByIndex is not allowed on partitioned-topic\");\n                                    }\n                                });\n                    }\n                }).thenCompose(ignore -> validateTopicOwnershipAsync(topicName, authoritative))\n                .thenCompose(__ -> getTopicReferenceAsync(topicName))\n                .thenCompose(topic -> {\n                    if (!(topic instanceof PersistentTopic persistentTopic)) {\n                        log.error()\n                                .attr(\"topic\", topicName)\n                                .log(\"Get message id by index on a non-persistent topic is not allowed\");\n                        return FutureUtil.failedFuture(new RestException(Status.METHOD_NOT_ALLOWED,\n                                \"Get message id by index on a non-persistent topic is not allowed\"));\n                    }\n                    ManagedLedger managedLedger = persistentTopic.getManagedLedger();\n                    Position lastPosition = managedLedger.getLastConfirmedEntry();\n                    Position firstPosition = managedLedger.getFirstPosition();\n                    if (firstPosition == null || lastPosition == null || firstPosition.equals(lastPosition)) {","sourceCodeStart":5714,"sourceCodeEnd":5750,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L5714-L5750","documentation":"Guard in the get-message-id-by-index path: the operation targets a partitioned (metadata) topic rather than a concrete partition, which is not allowed; the request should be issued against an individual partition topic.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:5732 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call the API on a specific partition (topic-partition-N)","Select the partition externally before querying by index"],"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-14T05:17:10.506Z"}