{"record":{"id":"230c0aa89e1af3b8","repo":"apache/kafka","slug":"klass-is-not-an-instance-of-org-apache-kafka-cli","errorCode":null,"errorMessage":"{klass} is not an instance of org.apache.kafka.clients.consumer.ConsumerPartitionAssignor","messagePattern":"(.+?) is not an instance of org\\.apache\\.kafka\\.clients\\.consumer\\.ConsumerPartitionAssignor","errorType":"validation","errorClass":"KafkaException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerPartitionAssignor.java","lineNumber":447,"sourceCode":"                    throw new KafkaException(klass + \" ClassNotFoundException exception occurred\", classNotFound);\n                }\n            }\n\n            if (klass instanceof Class<?>) {\n                Object assignor = Utils.newInstance((Class<?>) klass);\n                if (assignor instanceof Configurable)\n                    ((Configurable) assignor).configure(configs);\n\n                if (assignor instanceof ConsumerPartitionAssignor) {\n                    String assignorName = ((ConsumerPartitionAssignor) assignor).name();\n                    if (assignorNameMap.containsKey(assignorName)) {\n                        throw new KafkaException(\"The assignor name: '\" + assignorName + \"' is used in more than one assignor: \" +\n                            assignorNameMap.get(assignorName) + \", \" + assignor.getClass().getName());\n                    }\n                    assignorNameMap.put(assignorName, assignor.getClass().getName());\n                    assignors.add((ConsumerPartitionAssignor) assignor);\n                } else {\n                    throw new KafkaException(klass + \" is not an instance of \" + ConsumerPartitionAssignor.class.getName());\n                }\n            } else {\n                throw new KafkaException(\"List contains element of type \" + klass.getClass().getName() + \", expected String or Class\");\n            }\n        }\n        return assignors;\n    }\n\n}\n","sourceCodeStart":429,"sourceCodeEnd":457,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerPartitionAssignor.java#L429-L457","documentation":"Thrown by ConsumerPartitionAssignor.getAssignorInstances when a class listed in partition.assignment.strategy instantiates successfully but does not implement ConsumerPartitionAssignor. The consumer validates the type before adding the instance, because every assignor must participate in the assign protocol. The message names the offending class so you can find the wrong entry in the config.","triggerScenarios":"Putting a fully-qualified class name in partition.assignment.strategy that points to a producer interceptor, serializer, or any arbitrary class instead of a ConsumerPartitionAssignor implementation; passing a Class object (rather than a String) that resolves to an unrelated type; refactoring that moved an assignor class but left the old FQN in config.","commonSituations":"Confusing partition.assignment.strategy with value.deserializer or interceptor.classes config keys; vendoring a class whose package/name is similar to a real assignor; copy-paste from docs that point at an internal abstract class rather than the concrete assignor.","solutions":["Check partition.assignment.strategy and replace the offending FQN with a concrete class implementing ConsumerPartitionAssignor (e.g. org.apache.kafka.clients.consumer.CooperativeStickyAssignor).","If the class is custom, make it 'implements ConsumerPartitionAssignor' and rebuild; recheck that the interface's methods (assign, name, etc.) are implemented.","Confirm you are not accidentally listing a base/abstract class or an assignor from a different Kafka module version."],"exampleFix":"// before\nprops.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG,\n    List.of(\"com.example.MyProducerInterceptor\"));\n\n// after\nprops.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG,\n    List.of(CooperativeStickyAssignor.class.getName()));","handlingStrategy":"validation","validationCode":"for (String fqn : configuredStrategies) {\n    Class<?> c = Utils.loadClass(fqn, Object.class);\n    if (!ConsumerPartitionAssignor.class.isAssignableFrom(c))\n        throw new IllegalArgumentException(fqn + \" does not implement ConsumerPartitionAssignor\");\n}","typeGuard":"static boolean isAssignor(Class<?> c) {\n    return ConsumerPartitionAssignor.class.isAssignableFrom(c);\n}","tryCatchPattern":"try {\n    consumer = new KafkaConsumer<>(props);\n} catch (KafkaException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"is not an instance of \" + ConsumerPartitionAssignor.class.getName())) {\n        // surface as a configuration error pointing at the offending FQN\n    }\n    throw e;\n}","preventionTips":["Prefer referencing built-in assignors by .class.getName() rather than hand-typed strings.","Add a CI check that loads and type-checks every partition.assignment.strategy entry against ConsumerPartitionAssignor.","Keep assignor classes in a dedicated package distinct from serializers/interceptors."],"tags":["consumer","partition-assignor","configuration","type-mismatch"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}