Parcourir la source

Fixing bug 2243 - Replication Factor validation (#2370)

Co-authored-by: Roman Zabaluev <rzabaluev@provectus.com>
Daniel Ching il y a 2 ans
Parent
commit
757bf9526e

+ 5 - 0
kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/TopicsService.java

@@ -259,6 +259,11 @@ public class TopicsService {
                 new ValidationException(
                     String.format("Topic already has replicationFactor %s.", actual)));
           }
+          if (requested <= 0) {
+            return Mono.error(
+                new ValidationException(
+                    String.format("Requested replication factor (%s) should be greater or equal to 1.", requested)));
+          }
           if (requested > brokersCount) {
             return Mono.error(
                 new ValidationException(

+ 2 - 1
kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml

@@ -592,6 +592,8 @@ paths:
                 $ref: '#/components/schemas/ReplicationFactorChangeResponse'
         404:
           description: Not found
+        400:
+          description: Bad Request
 
   /api/clusters/{clusterName}/topics/{topicName}/messages:
     get:
@@ -3052,7 +3054,6 @@ components:
       properties:
         totalReplicationFactor:
           type: integer
-          minimum: 1
       required:
         - totalReplicationFactor