apache/pulsar · error · RestException
GetMessageIDByIndex is not allowed on partitioned-topic
Error message
GetMessageIDByIndex is not allowed on partitioned-topic
What it means
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.
Source
Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:5732
if (index == null || index < 0) {
return FutureUtil.failedFuture(new RestException(Status.NOT_FOUND,
"Invalid message index: " + index));
}
int partitionIndex = topicName.getPartitionIndex();
return validateTopicOperationAsync(topicName, TopicOperation.PEEK_MESSAGES)
.thenCompose(__ -> validateGlobalNamespaceOwnershipAsync(namespaceName))
.thenCompose(__ -> {
if (topicName.isPartitioned()) {
return CompletableFuture.completedFuture(null);
} else {
return getPartitionedTopicMetadataAsync(topicName, authoritative, false)
.thenAccept(topicMetadata -> {
if (topicMetadata.partitions > 0) {
log.warn()
.attr("topic", topicName)
.log("Not supported getMessageIdByIndex operation on"
+ " partitioned-topic");
throw new RestException(Status.METHOD_NOT_ALLOWED,
"GetMessageIDByIndex is not allowed on partitioned-topic");
}
});
}
}).thenCompose(ignore -> validateTopicOwnershipAsync(topicName, authoritative))
.thenCompose(__ -> getTopicReferenceAsync(topicName))
.thenCompose(topic -> {
if (!(topic instanceof PersistentTopic persistentTopic)) {
log.error()
.attr("topic", topicName)
.log("Get message id by index on a non-persistent topic is not allowed");
return FutureUtil.failedFuture(new RestException(Status.METHOD_NOT_ALLOWED,
"Get message id by index on a non-persistent topic is not allowed"));
}
ManagedLedger managedLedger = persistentTopic.getManagedLedger();
Position lastPosition = managedLedger.getLastConfirmedEntry();
Position firstPosition = managedLedger.getFirstPosition();
if (firstPosition == null || lastPosition == null || firstPosition.equals(lastPosition)) {View on GitHub (pinned to 820761864e)
Solutions
- Call the API on a specific partition (topic-partition-N)
- Select the partition externally before querying by index
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:5732 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/ec309bb4fa92d22b.
Report an issue: GitHub.