showuon commented on code in PR #22384:
URL: https://github.com/apache/kafka/pull/22384#discussion_r3323506973


##########
metadata/src/main/java/org/apache/kafka/metadata/storage/Formatter.java:
##########
@@ -236,6 +236,17 @@ public void run() throws Exception {
         if (clusterId == null) {
             throw new FormatterException("You must specify the cluster id.");
         }
+        try {
+            if (clusterId.contains("=")) {
+                throw new FormatterException("The specified cluster id, " + 
clusterId + " contains padding and is invalid");
+            }
+            Uuid uuid = Uuid.fromString(clusterId);
+            if (Uuid.RESERVED.contains(uuid)) {
+                throw new FormatterException("The specified cluster id, " + 
clusterId + " is reserved");
+            }

Review Comment:
   Let's also validate the starting `-` sign.



##########
metadata/src/main/java/org/apache/kafka/metadata/storage/Formatter.java:
##########
@@ -236,6 +236,17 @@ public void run() throws Exception {
         if (clusterId == null) {
             throw new FormatterException("You must specify the cluster id.");
         }
+        try {
+            if (clusterId.contains("=")) {
+                throw new FormatterException("The specified cluster id, " + 
clusterId + " contains padding and is invalid");

Review Comment:
   Our [randomUuid 
method](https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/Uuid.java#L71-L76)
 is possible to output the uuid contains `=` sign:
   >  This will not generate a UUID equal to 0, 1, or one whose string 
representation starts with a dash ("-")
   
   So is this the expected validation?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to