apache/pulsar · error · RestException

Topic is not the partitioned topic.

Error message

Topic %s is not the partitioned topic.

What it means

internalUpdatePartitionedTopicAsync was invoked on a topic whose metadata shows it is not a partitioned topic; the update-partitions operation requires an existing partitioned topic and is rejected otherwise.

Solutions

  1. Create the partitioned topic first with the partitions option
  2. Call the update API on the partitioned topic name, not a partition or plain topic
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:383 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/81a954b0e554a69d. Report an issue: GitHub.

Appendix: source

Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:383

    }

    /**
     * It updates number of partitions of an existing partitioned topic. It requires partitioned-topic to
     * already exist and number of new partitions must be greater than existing number of partitions. Decrementing
     * number of partitions requires deletion of topic which is not supported.
     *
     * @exception RestException Unprocessable entity, status code: 422. throw it when some pre-check failed.
     * @exception RestException Internal Server Error, status code: 500. throw it when get unknown Exception
     */
    protected @NonNull CompletableFuture<Void> internalUpdatePartitionedTopicAsync(int expectPartitions,
                                                                                   boolean updateLocal,
                                                                                   boolean force) {
        PulsarService pulsarService = pulsar();
        return pulsarService.getBrokerService().fetchPartitionedTopicMetadataAsync(topicName)
            .thenCompose(partitionedTopicMetadata -> {
                int currentMetadataPartitions = partitionedTopicMetadata.partitions;
                if (currentMetadataPartitions <= 0) {
                    throw new RestException(Status.CONFLICT /* Unprocessable entity*/,
                            String.format("Topic %s is not the partitioned topic.", topicName));
                }
                if (expectPartitions < currentMetadataPartitions) {
                    throw new RestException(422 /* Unprocessable entity*/,
                            String.format("Desired partitions %s can't be less than the current partitions %s.",
                                    expectPartitions, currentMetadataPartitions));
                }
                int brokerMaximumPartitionsPerTopic = pulsarService.getConfiguration()
                        .getMaxNumPartitionsPerPartitionedTopic();
                if (brokerMaximumPartitionsPerTopic > 0 && expectPartitions > brokerMaximumPartitionsPerTopic) {
                    throw new RestException(422 /* Unprocessable entity*/,
                            String.format("Desired partitions %s can't be greater than the maximum partitions per"
                                            + " topic %s.",
                                    expectPartitions, brokerMaximumPartitionsPerTopic));
                }
                final PulsarAdmin admin;
                try {
                    admin = pulsarService.getAdminClient();

View on GitHub (pinned to 820761864e)