t8y2/dbx · error · UnknownTopicOrPartitionException
Kafka topic does not exist: " + name
Error message
Kafka topic does not exist: " + name
What it means
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.
Source
Thrown at agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java:741
AdminClient admin = requireAdmin();
int timeout = requestTimeout(params);
String name = stringOrEmpty(params, "name");
try {
return modernTopicStats(admin, name, timeout);
} catch (Exception error) {
if (!hasUnsupportedVersionException(error)) {
throw error;
}
return legacyTopicStats(name, timeout);
}
}
private static Object modernTopicStats(AdminClient admin, String name, int timeout) throws Exception {
TopicDescription desc = admin.describeTopics(Collections.singletonList(name))
.allTopicNames().get(timeout, TimeUnit.MILLISECONDS).get(name);
if (desc == null) {
throw new UnknownTopicOrPartitionException("Kafka topic does not exist: " + name);
}
// Collect offsets for size estimation
Map<TopicPartition, ListOffsetsResult.ListOffsetsResultInfo> endOffsets = new LinkedHashMap<>();
Map<TopicPartition, ListOffsetsResult.ListOffsetsResultInfo> beginOffsets = new LinkedHashMap<>();
for (TopicPartitionInfo pi : desc.partitions()) {
TopicPartition tp = new TopicPartition(name, pi.partition());
endOffsets.put(tp, admin.listOffsets(Collections.singletonMap(tp, OffsetSpec.latest()))
.all().get(timeout, TimeUnit.MILLISECONDS).get(tp));
beginOffsets.put(tp, admin.listOffsets(Collections.singletonMap(tp, OffsetSpec.earliest()))
.all().get(timeout, TimeUnit.MILLISECONDS).get(tp));
}
long totalMessages = 0;
List<Map<String, Object>> partitionStats = new ArrayList<>();
for (TopicPartitionInfo pi : desc.partitions()) {
TopicPartition tp = new TopicPartition(name, pi.partition());
long end = endOffsets.get(tp).offset();View on GitHub (pinned to c0390bff16)
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.
Example fix
// before
agent.topicStats("order-eventts", 5000); // typo: topic missing
// after
agent.topicStats("order-events", 5000); // exact existing topic name Defensive patterns
Strategy: validation
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Not connected. Call connect first.
- Unknown method: " + method
- Kafka Agent is not connected
- Kafka broker does not support " + op.opType() + " config ope
- offsets must be an array
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/953eed2b87b5a733.
Report an issue: GitHub.