{"record":{"id":"953eed2b87b5a733","repo":"t8y2/dbx","slug":"kafka-topic-does-not-exist-name","errorCode":null,"errorMessage":"Kafka topic does not exist: \" + name","messagePattern":"Kafka topic does not exist: \" \\+ name","errorType":"exception","errorClass":"UnknownTopicOrPartitionException","httpStatus":null,"severity":"error","filePath":"agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java","lineNumber":741,"sourceCode":"        AdminClient admin = requireAdmin();\n        int timeout = requestTimeout(params);\n        String name = stringOrEmpty(params, \"name\");\n\n        try {\n            return modernTopicStats(admin, name, timeout);\n        } catch (Exception error) {\n            if (!hasUnsupportedVersionException(error)) {\n                throw error;\n            }\n            return legacyTopicStats(name, timeout);\n        }\n    }\n\n    private static Object modernTopicStats(AdminClient admin, String name, int timeout) throws Exception {\n        TopicDescription desc = admin.describeTopics(Collections.singletonList(name))\n            .allTopicNames().get(timeout, TimeUnit.MILLISECONDS).get(name);\n        if (desc == null) {\n            throw new UnknownTopicOrPartitionException(\"Kafka topic does not exist: \" + name);\n        }\n\n        // Collect offsets for size estimation\n        Map<TopicPartition, ListOffsetsResult.ListOffsetsResultInfo> endOffsets = new LinkedHashMap<>();\n        Map<TopicPartition, ListOffsetsResult.ListOffsetsResultInfo> beginOffsets = new LinkedHashMap<>();\n        for (TopicPartitionInfo pi : desc.partitions()) {\n            TopicPartition tp = new TopicPartition(name, pi.partition());\n            endOffsets.put(tp, admin.listOffsets(Collections.singletonMap(tp, OffsetSpec.latest()))\n                .all().get(timeout, TimeUnit.MILLISECONDS).get(tp));\n            beginOffsets.put(tp, admin.listOffsets(Collections.singletonMap(tp, OffsetSpec.earliest()))\n                .all().get(timeout, TimeUnit.MILLISECONDS).get(tp));\n        }\n\n        long totalMessages = 0;\n        List<Map<String, Object>> partitionStats = new ArrayList<>();\n        for (TopicPartitionInfo pi : desc.partitions()) {\n            TopicPartition tp = new TopicPartition(name, pi.partition());\n            long end = endOffsets.get(tp).offset();","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java#L723-L759","documentation":"KafkaAgent throws UnknownTopicOrPartitionException with this message when a topic-stats lookup finds no topic with the given name on the Kafka cluster. In the modern code path, describeTopics(...).allTopicNames().get(...) returns a map; if the requested name is absent (desc == null), the agent signals the caller that the topic does not exist. This typically surfaces as a wrapped ExecutionException/TimeoutException-free null path, meaning the broker metadata simply has no such topic.","triggerScenarios":"Calling the Kafka Agent's topic stats/inspect operation with a topic name that does not exist on the connected cluster; describeTopics returns metadata without the requested name within the timeout, yielding a null TopicDescription.","commonSituations":"Typo in the topic name; pointing the agent at the wrong cluster/environment (e.g. staging broker where the topic was never created); topic was deleted by a retention/cleanup job; topic not yet created because auto-create is disabled on the broker and no producer has written to it.","solutions":["List the cluster's topics (via the agent's topic listing or kafka-topics.sh --list) and confirm the exact topic name, checking for typos and case.","Verify the agent's connection config points at the intended Kafka cluster (correct bootstrap.servers / environment).","Create the missing topic if it should exist (kafka-topics.sh --create, or let the producing client create it if auto.create.topics.enable is true).","If the topic was recently created, retry after allowing cluster metadata to propagate.","Increase the timeout argument if the operation timed out before metadata returned, then retry."],"exampleFix":"// before\nagent.topicStats(\"order-eventts\", 5000); // typo: topic missing\n// after\nagent.topicStats(\"order-events\", 5000); // exact existing topic name","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["kafka","topic-not-found","admin-client"],"backgroundTag":"kafka-topic-does-not-exist","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}