{"record":{"id":"221bfa914c0f108d","repo":"apache/pulsar","slug":"desired-partitions-s-can-t-be-greater-than-the-ma","errorCode":null,"errorMessage":"Desired partitions %s can't be greater than the maximum partitions per topic %s.","messagePattern":"Desired partitions (.+?) can't be greater than the maximum partitions per topic (.+?)\\.","errorType":"http","errorClass":"RestException","httpStatus":422,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java","lineNumber":394,"sourceCode":"                                                                                   boolean updateLocal,\n                                                                                   boolean force) {\n        PulsarService pulsarService = pulsar();\n        return pulsarService.getBrokerService().fetchPartitionedTopicMetadataAsync(topicName)\n            .thenCompose(partitionedTopicMetadata -> {\n                int currentMetadataPartitions = partitionedTopicMetadata.partitions;\n                if (currentMetadataPartitions <= 0) {\n                    throw new RestException(Status.CONFLICT /* Unprocessable entity*/,\n                            String.format(\"Topic %s is not the partitioned topic.\", topicName));\n                }\n                if (expectPartitions < currentMetadataPartitions) {\n                    throw new RestException(422 /* Unprocessable entity*/,\n                            String.format(\"Desired partitions %s can't be less than the current partitions %s.\",\n                                    expectPartitions, currentMetadataPartitions));\n                }\n                int brokerMaximumPartitionsPerTopic = pulsarService.getConfiguration()\n                        .getMaxNumPartitionsPerPartitionedTopic();\n                if (brokerMaximumPartitionsPerTopic > 0 && expectPartitions > brokerMaximumPartitionsPerTopic) {\n                    throw new RestException(422 /* Unprocessable entity*/,\n                            String.format(\"Desired partitions %s can't be greater than the maximum partitions per\"\n                                            + \" topic %s.\",\n                                    expectPartitions, brokerMaximumPartitionsPerTopic));\n                }\n                final PulsarAdmin admin;\n                try {\n                    admin = pulsarService.getAdminClient();\n                } catch (PulsarServerException ex) {\n                    throw new RestException(Status.INTERNAL_SERVER_ERROR, Throwables.getRootCause(ex));\n                }\n                final CompletableFuture<Void> checkFuture;\n                if (!force) {\n                    checkFuture = admin.topics().getListAsync(topicName.getNamespace(), topicName.getDomain())\n                            .thenAccept(topics -> {\n                                final List<TopicName> existingPartitions = topics.stream()\n                                        .map(TopicName::get)\n                                        .filter(candidateTopicName -> candidateTopicName.getPartitionedTopicName()\n                                                .equals(topicName.getPartitionedTopicName()))","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L376-L412","documentation":"internalUpdatePartitionedTopicAsync pre-check failure (422): the requested partition count exceeds the cluster's maximum allowed partitions per topic, so the update is rejected to prevent creating more partitions than the broker configuration permits.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:394 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Request a count within maxPartitionsPerTopic","Ask the admin to raise maxPartitionsPerTopic if a larger topic is genuinely needed"],"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"}