ijuma commented on a change in pull request #10584:
URL: https://github.com/apache/kafka/pull/10584#discussion_r635206076



##########
File path: core/src/main/scala/kafka/server/KafkaApis.scala
##########
@@ -1142,6 +1142,19 @@ class KafkaApis(val requestChannel: RequestChannel,
     val metadataRequest = request.body[MetadataRequest]
     val requestVersion = request.header.apiVersion
 
+    // Topic IDs are not supported for versions 10 and 11. Topic names can not 
be null in these versions.
+    if (metadataRequest.version() >= 10 && !metadataRequest.isAllTopics) {
+      metadataRequest.data().topics().forEach{ topic =>
+        // If null, set to the empty string, since the response does not allow 
null.
+        if (topic.name() == null) {
+          topic.setName("")
+          throw new InvalidRequestException(s"Topic name can not be null for 
version ${metadataRequest.version()}")
+        } else if (topic.topicId() != Uuid.ZERO_UUID) {
+          throw new InvalidRequestException(s"Topic IDs are not supported in 
requests for version ${metadataRequest.version()}")
+        }
+      }
+    }

Review comment:
       Can we not do such validation in the request class?




-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to