{"record":{"id":"03af3f1383277397","repo":"apache/kafka","slug":"the-topiccollection-topics-provided-did-not-mat-03af3f","errorCode":null,"errorMessage":"The TopicCollection: {topics} provided did not match any supported classes for describeTopics.","messagePattern":"The TopicCollection: (.+?) provided did not match any supported classes for describeTopics\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java","lineNumber":2251,"sourceCode":"                topicListingFuture.complete(topicListing);\n            }\n\n            @Override\n            void handleFailure(Throwable throwable) {\n                topicListingFuture.completeExceptionally(throwable);\n            }\n        }, now);\n        return new ListTopicsResult(topicListingFuture);\n    }\n\n    @Override\n    public DescribeTopicsResult describeTopics(final TopicCollection topics, DescribeTopicsOptions options) {\n        if (topics instanceof TopicIdCollection)\n            return DescribeTopicsResult.ofTopicIds(handleDescribeTopicsByIds(((TopicIdCollection) topics).topicIds(), options));\n        else if (topics instanceof TopicNameCollection)\n            return DescribeTopicsResult.ofTopicNames(handleDescribeTopicsByNamesWithDescribeTopicPartitionsApi(((TopicNameCollection) topics).topicNames(), options));\n        else\n            throw new IllegalArgumentException(\"The TopicCollection: \" + topics + \" provided did not match any supported classes for describeTopics.\");\n    }\n\n    private Call generateDescribeTopicsCallWithMetadataApi(\n        List<String> topicNamesList,\n        Map<String, KafkaFutureImpl<TopicDescription>> topicFutures,\n        DescribeTopicsOptions options,\n        long now\n    ) {\n        return new Call(\"describeTopics\", calcDeadlineMs(now, options.timeoutMs()),\n            new LeastLoadedNodeProvider()) {\n\n            private boolean supportsDisablingTopicCreation = true;\n\n            @Override\n            MetadataRequest.Builder createRequest(int timeoutMs) {\n                if (supportsDisablingTopicCreation)\n                    return new MetadataRequest.Builder(new MetadataRequestData()\n                        .setTopics(convertToMetadataRequestTopic(topicNamesList))","sourceCodeStart":2233,"sourceCodeEnd":2269,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java#L2233-L2269","documentation":"An IllegalArgumentException thrown by KafkaAdminClient.describeTopics(TopicCollection, ...) when the TopicCollection subclass is neither TopicIdCollection nor TopicNameCollection. Identical shape to the deleteTopics guard: only the two built-in subclasses are accepted.","triggerScenarios":"Passing a custom TopicCollection subclass or null to admin.describeTopics(...). Subclassing TopicCollection and passing the subclass.","commonSituations":"Wrapper libraries that introduce their own TopicCollection type; null values from optional chaining; refactoring that left an outdated collection type in place.","solutions":["Build the collection with TopicCollection.ofTopicNames(...) or TopicCollection.ofTopicIds(...).","Guarantee the argument is non-null and one of the two supported concrete subclasses.","Unwrap any custom wrapper to a supported type before the call."],"exampleFix":"// before\nadmin.describeTopics(customCollection, opts);\n\n// after\nadmin.describeTopics(TopicCollection.ofTopicIds(List.of(Uuid.fromUuidString(\"...\"))), opts);","handlingStrategy":"validation","validationCode":"TopicCollection topics = (ids != null && !ids.isEmpty())\n    ? TopicCollection.ofTopicIds(ids)\n    : TopicCollection.ofTopicNames(names);\nadmin.describeTopics(topics, options);","typeGuard":"static boolean isSupportedTopicCollection(TopicCollection c) {\n    return c instanceof TopicIdCollection || c instanceof TopicNameCollection;\n}","tryCatchPattern":null,"preventionTips":["Always build TopicCollection via the ofTopicNames/ofTopicIds factories.","Unwrap any custom wrapper type before calling describeTopics."],"tags":["kafka-admin","topic-management","argument-validation","api-misuse"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}