apache/pulsar · error · RestException

Invalid cluster id: ${clusterId}

Error message

Invalid cluster id: ${clusterId}

What it means

Setting topic-level replication policies failed because the request includes a cluster that is not in the namespace-level replication set; global topic policies can only copy to namespace-replicated clusters (412).

Source

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

                                if (v.replication_clusters.contains(clusterId)) {
                                    continue;
                                }
                                return FutureUtil.failedFuture(new RestException(Response.Status.PRECONDITION_FAILED,
                                    "The policies at the global topic level will only be copied to the clusters"
                                    + " included in the namespace level replication. Therefore, please do not set the"
                                    + " policies including other clusters"));
                            }
                            return CompletableFuture.completedFuture(null);
                        });
                    }
                    return CompletableFuture.completedFuture(null);
                })
                .thenCompose(__ -> clustersAsync())
                .thenCompose(clusters -> {
                    List<CompletableFuture<Void>> futures = new ArrayList<>(replicationClustersSet.size());
                    for (String clusterId : replicationClustersSet) {
                        if (!clusters.contains(clusterId)) {
                            throw new RestException(Status.FORBIDDEN, "Invalid cluster id: " + clusterId);
                        }
                        futures.add(validatePeerClusterConflictAsync(clusterId, replicationClustersSet));
                        futures.add(validateClusterForTenantAsync(namespaceName.getTenant(), clusterId));
                    }
                    return FutureUtil.waitForAll(futures);
                }).thenCompose(__ -> {
                    if (!pulsar().getConfig().isCreateTopicToRemoteClusterForReplication()) {
                        log.info()
                                .attr("topic", topicName)
                                .attr("clusters", replicationClustersSet.stream().filter(v ->
                                        !pulsar().getConfig().getClusterName().equals(v)).collect(Collectors
                                                .toList())).log("Skip creating partitioned for topic for the remote"
                                                        + " clusters");
                        return CompletableFuture.completedFuture(null);
                    }
                    // Sync to create partitioned topic on the remote cluster if needed.
                    TopicName topicNameWithoutPartition = TopicName.get(topicName.getPartitionedTopicName());
                    return pulsar().getPulsarResources().getNamespaceResources().getPartitionedTopicResources()

View on GitHub (pinned to 820761864e)

Solutions

  1. Add the cluster to the namespace's replicationClusters first
  2. Restrict the topic-level policy to clusters already in the namespace replication set
Defensive patterns

Strategy: validation

When it happens

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