Repository: provectus/kafka-ui
Issue: [BE] Bug: UnsupportedVersionException: includeClusterAuthorizedOperations
Labels: type/bug
scope/backend
status/accepted
status/confirmed

application.yml
```
    kafka:
      clusters:
        - name: qsmzq-prod
          bootstrapServers: node1:9092,node2:9092,node3:9092
          properties:
            security.protocol: SASL_PLAINTEXT
            sasl.mechanism: SCRAM-SHA-256
            sasl.jaas.config: 'org.apache.kafka.common.security.scram.ScramLoginModule required username="kafka" password="password";'

    spring:
      jmx:
        enabled: false
    auth:
      type: DISABLED
```


```
java.lang.IllegalStateException: Error while creating AdminClient for Cluster qsmzq-prod
	at com.provectus.kafka.ui.service.AdminClientServiceImpl.lambda$createAdminClient$3(AdminClientServiceImpl.java:45)
	at reactor.core.publisher.Mono.lambda$onErrorMap$31(Mono.java:3776)
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)
	at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onError(FluxHide.java:142)
	at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:134)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onError(Operators.java:2063)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onError(MonoIgnoreThen.java:278)
	at reactor.core.publisher.MonoPublishOn$PublishOnSubscriber.run(MonoPublishOn.java:187)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.apache.kafka.common.errors.UnsupportedVersionException: Attempted to write a non-default includeClusterAuthorizedOperations at version 7
```


I used same config at v0.4.0, everything works as expected.

Issue comments:
@fisherwei hi, please share a full stacktrace  (you've omitted the part below)
Same here. Full stacktrace included, after this it just repeats.

```provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: java.lang.IllegalStateException: Error while creating AdminClient for Cluster XXX
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at com.provectus.kafka.ui.service.AdminClientServiceImpl.lambda$createAdminClient$3(AdminClientServiceImpl.java:45)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.Mono.lambda$onErrorMap$31(Mono.java:3776)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onError(FluxHide.java:142)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:134)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onError(Operators.java:2063)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onError(MonoIgnoreThen.java:278)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.publisher.MonoPublishOn$PublishOnSubscriber.run(MonoPublishOn.java:187)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #011at java.base/java.lang.Thread.run(Thread.java:833)
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: Caused by: org.apache.kafka.common.errors.UnsupportedVersionException: Attempted to write a non-default includeClusterAuthorizedOperations at version 5
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #033[30m2022-12-27 15:18:36,575#033[0;39m #033[39mDEBUG#033[0;39m [#033[34mparallel-11#033[0;39m] #033[33mc.p.k.u.s.ClustersStatisticsScheduler#033[0;39m: Metrics updated for cluster: XXX
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #033[30m2022-12-27 15:18:36,592#033[0;39m #033[34mINFO #033[0;39m [#033[34mkafka-admin-client-thread | kafka-ui-admin-client-1672153416196#033[0;39m] #033[33mo.a.k.c.NetworkClient#033[0;39m: [AdminClient clientId=kafka-ui-admin-client-1672153416196] Node 1004 
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #033[30m2022-12-27 15:18:36,640#033[0;39m #033[34mINFO #033[0;39m [#033[34mkafka-admin-client-thread | kafka-ui-admin-client-1672153716196#033[0;39m] #033[33mo.a.k.c.NetworkClient#033[0;39m: [AdminClient clientId=kafka-ui-admin-client-1672153716196] Node 1 
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #033[30m2022-12-27 15:18:36,697#033[0;39m #033[34mINFO #033[0;39m [#033[34mkafka-admin-client-thread | kafka-ui-admin-client-1672153116196#033[0;39m] #033[33mo.a.k.c.NetworkClient#033[0;39m: [AdminClient clientId=kafka-ui-admin-client-1672153116196] Node 1004 
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #033[30m2022-12-27 15:18:36,897#033[0;39m #033[34mINFO #033[0;39m [#033[34mkafka-admin-client-thread | kafka-ui-admin-client-1672153416196#033[0;39m] #033[33mo.a.k.c.NetworkClient#033[0;39m: [AdminClient clientId=kafka-ui-admin-client-1672153416196] Node 2 
provectuslabs/kafka-ui:v0.5.0|c94d85724408[2661]: #033[30m2022-12-27 15:18:36,965#033[0;39m #033[34mINFO #033[0;39m [#033[34mkafka-admin-client-thread | kafka-ui-admin-client-1672152516196#033[0;39m] #033[33mo.a.k.c.NetworkClient#033[0;39m: [AdminClient clientId=kafka-ui-admin-client-1672152516196] Node 1002 
```


Thanks. It seems like your kafka doesn't support ACLs operations we do, we'll take a look for a workaround.
I had this issue. The issue is that your kafka version does not support includeAuthorizedOperations(true). A work around is setting this to false

In this method [https://github.com/provectus/kafka-ui/blob/master/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/ReactiveAdminClient.java#L306](url) change it to false and it will work 
Hello @fisherwei  , thank you for ticket. 
Can you please check if it was fixed with `master` tag? If so, we will add fix this to 0.5.x bugfix release.
I didn't open the ticket but had the same problem. `master` works for us 👍 

Thanks! 🙏 
@RoccoMathijn , thank you for confirmation
When do you plan to push an official 0.5.x patch image with this fix?
@kewitschka you can pull master image for now

Pull request review comments:

Patch that resolved the issue:
diff --git a/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/ReactiveAdminClient.java b/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/ReactiveAdminClient.java
index b06716e6314..1ffbd429180 100644
--- a/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/ReactiveAdminClient.java
+++ b/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/ReactiveAdminClient.java
@@ -43,6 +43,7 @@
 import org.apache.kafka.clients.admin.ConsumerGroupDescription;
 import org.apache.kafka.clients.admin.ConsumerGroupListing;
 import org.apache.kafka.clients.admin.DescribeClusterOptions;
+import org.apache.kafka.clients.admin.DescribeClusterResult;
 import org.apache.kafka.clients.admin.DescribeConfigsOptions;
 import org.apache.kafka.clients.admin.ListConsumerGroupOffsetsOptions;
 import org.apache.kafka.clients.admin.ListOffsetsResult;
@@ -80,7 +81,8 @@ public class ReactiveAdminClient implements Closeable {
 
   private enum SupportedFeature {
     INCREMENTAL_ALTER_CONFIGS(2.3f),
-    CONFIG_DOCUMENTATION_RETRIEVAL(2.6f);
+    CONFIG_DOCUMENTATION_RETRIEVAL(2.6f),
+    DESCRIBE_CLUSTER_INCLUDE_AUTHORIZED_OPERATIONS(2.3f);
 
     private final float sinceVersion;
 
@@ -300,11 +302,14 @@ public Mono<Map<Integer, Map<String, DescribeLogDirsResponse.LogDirInfo>>> descr
   }
 
   public Mono<ClusterDescription> describeCluster() {
-    return describeClusterImpl(client);
+    return describeClusterImpl(client, features);
   }
 
-  private static Mono<ClusterDescription> describeClusterImpl(AdminClient client) {
-    var result = client.describeCluster(new DescribeClusterOptions().includeAuthorizedOperations(true));
+  private static Mono<ClusterDescription> describeClusterImpl(AdminClient client, Set<SupportedFeature> features) {
+    boolean includeAuthorizedOperations =
+        features.contains(SupportedFeature.DESCRIBE_CLUSTER_INCLUDE_AUTHORIZED_OPERATIONS);
+    DescribeClusterResult result = client.describeCluster(
+        new DescribeClusterOptions().includeAuthorizedOperations(includeAuthorizedOperations));
     var allOfFuture = KafkaFuture.allOf(
         result.controller(), result.clusterId(), result.nodes(), result.authorizedOperations());
     return toMono(allOfFuture).then(
@@ -320,7 +325,7 @@ private static Mono<ClusterDescription> describeClusterImpl(AdminClient client)
   }
 
   private static Mono<String> getClusterVersion(AdminClient client) {
-    return describeClusterImpl(client)
+    return describeClusterImpl(client, Set.of())
         // choosing node from which we will get configs (starting with controller)
         .flatMap(descr -> descr.controller != null
             ? Mono.just(descr.controller)


Test patch: