{"record":{"id":"6b7cf5a197bba696","repo":"apache/pulsar","slug":"desired-partitions-s-can-t-be-less-than-the-curre","errorCode":null,"errorMessage":"Desired partitions %s can't be less than the current partitions %s.","messagePattern":"Desired partitions (.+?) can't be less than the current partitions (.+?)\\.","errorType":"http","errorClass":"RestException","httpStatus":422,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java","lineNumber":387,"sourceCode":"     * already exist and number of new partitions must be greater than existing number of partitions. Decrementing\n     * number of partitions requires deletion of topic which is not supported.\n     *\n     * @exception RestException Unprocessable entity, status code: 422. throw it when some pre-check failed.\n     * @exception RestException Internal Server Error, status code: 500. throw it when get unknown Exception\n     */\n    protected @NonNull CompletableFuture<Void> internalUpdatePartitionedTopicAsync(int expectPartitions,\n                                                                                   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;","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L369-L405","documentation":"internalUpdatePartitionedTopicAsync pre-check failure (422): the requested partition count is lower than the topic's current partition count. Partition counts can only grow because decrementing would require deleting partitions/topics, which is not supported.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:387 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Request a partition count greater than or equal to the current count","To shrink, delete and recreate the partitioned topic (data loss) after draining it"],"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"}