junrao commented on code in PR #16443:
URL: https://github.com/apache/kafka/pull/16443#discussion_r1772320884


##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -2305,11 +2307,34 @@ public CompletableFuture<UpdateFeaturesResponseData> 
updateFeatures(
         }).thenApply(result -> {
             UpdateFeaturesResponseData responseData = new 
UpdateFeaturesResponseData();
             responseData.setResults(new 
UpdateFeaturesResponseData.UpdatableFeatureResultCollection(result.size()));
-            result.forEach((featureName, error) -> responseData.results().add(
-                new UpdateFeaturesResponseData.UpdatableFeatureResult()
-                    .setFeature(featureName)
-                    .setErrorCode(error.error().code())
-                    .setErrorMessage(error.message())));
+            Optional<Entry<String, ApiError>> errorEntry = Optional.empty();
+            if (context.requestHeader().requestApiVersion() > 1) {
+                Stream<Entry<String, ApiError>> errorEntries = 
result.entrySet().stream().filter(entry ->
+                        !entry.getValue().error().equals(Errors.NONE));
+                errorEntry = errorEntries.findFirst();
+            }
+                
+            if (errorEntry.isPresent()) {
+                String errorFeatureName = errorEntry.get().getKey();
+                ApiError topError = errorEntry.get().getValue();
+                String errorString = errorFeatureName + ":" + 
topError.error().exceptionName() + " (" + topError.message() + ")";
+                
responseData.setErrorCode(Errors.INVALID_UPDATE_VERSION.code());

Review Comment:
   Ok, but is ControllerResult.response returned from 
`featureControl.updateFeatures` supposed to contain the error code for the 
client?



##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -3603,13 +3603,16 @@ class KafkaApis(val requestChannel: RequestChannel,
     def sendResponseCallback(errors: Either[ApiError, Map[String, ApiError]]): 
Unit = {
       def createResponse(throttleTimeMs: Int): UpdateFeaturesResponse = {
         errors match {
+          // Hard-code version to 1 since version 2 will not be implemented 
for 4.0

Review Comment:
   Got it. Perhaps make it clear that this is for ZK, which is not supported in 
4.0.



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