{"record":{"id":"a5d9c797cafc5678","repo":"quarkusio/quarkus","slug":"topic-doesn-t-exist-topic","errorCode":null,"errorMessage":"Topic doesn't exist: \" + topic","messagePattern":"Topic doesn't exist: \" \\+ topic","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"integration-tests/kafka-devservices/src/main/java/io/quarkus/it/kafka/KafkaAdminManager.java","lineNumber":54,"sourceCode":"    }\n\n    @PreDestroy\n    void cleanup() {\n        admin.close();\n    }\n\n    public int partitions(String topic) {\n\n        TopicDescription topicDescription;\n        try {\n            Map<String, TopicDescription> partitions = admin.describeTopics(Collections.singletonList(topic))\n                    .allTopicNames().get(2000, TimeUnit.MILLISECONDS);\n            topicDescription = partitions.get(topic);\n        } catch (InterruptedException | ExecutionException | TimeoutException e) {\n            throw new RuntimeException(e);\n        }\n        if (topicDescription == null) {\n            throw new IllegalArgumentException(\"Topic doesn't exist: \" + topic);\n        }\n        return topicDescription.partitions().size();\n    }\n\n    int port() throws InterruptedException, ExecutionException {\n        return admin.describeCluster().controller().get().port();\n    }\n\n    String image() throws InterruptedException, ExecutionException {\n        // By observation, the red panda does not return anything for the supported features call\n        // It would be nice to have a more robust check, but hopefully this fragile check is good enough\n        boolean isRedPanda = admin.describeFeatures().featureMetadata().get().supportedFeatures().size() == 0;\n        return isRedPanda ? \"redpanda\" : \"kafka-native\";\n    }\n\n}\n","sourceCodeStart":36,"sourceCodeEnd":71,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/kafka-devservices/src/main/java/io/quarkus/it/kafka/KafkaAdminManager.java#L36-L71","documentation":"KafkaAdminManager.partitions() describes a Kafka topic via AdminClient.describeTopics and throws IllegalArgumentException('Topic doesn't exist: <topic>') when the returned map contains no entry for the requested topic name. Note describeTopics can also surface unknown-topic errors as ExecutionException; this branch handles the case where the call succeeded but the topic was absent from the result map. It indicates a mismatch between the topic name requested and the topics that exist on the broker.","triggerScenarios":"Calling partitions(\"some-topic\") when the topic was never created, was deleted, or the name is misspelled/case-mismatched — e.g. Dev Services for Kafka has not yet created the topic, or the configured kafka.topic name differs from the created topic.","commonSituations":"Dev Services environment where topic auto-creation hasn't run yet or the broker (redpanda/kafka-native) reset state; tests pointing at a different bootstrap server than where the topic exists; typos in topic names passed via config.","solutions":["Create the topic before calling partitions (via AdminClient.createTopics or Kafka Connect/newTopic @Produces beans)","Check the topic name spelling/case against admin.listTopics() output","Verify kafka.bootstrap.servers points to the broker/Dev Service instance where the topic actually exists","Increase wait/retry if Dev Services has not finished creating topics before the call (the 2000ms timeout is tight)"],"exampleFix":"// before\nif (topicDescription == null) {\n    throw new IllegalArgumentException(\"Topic doesn't exist: \" + topic);\n}\n// after\nif (topicDescription == null) {\n    admin.createTopics(Collections.singletonList(new NewTopic(topic, 1, (short) 1))).all().get();\n    topicDescription = admin.describeTopics(Collections.singletonList(topic)).allTopicNames().get(topic);\n}","handlingStrategy":"validation","validationCode":"Set<String> existing = admin.listTopics().names().get(5, TimeUnit.SECONDS);\nif (!existing.contains(topic)) {\n    throw new IllegalStateException(\"Topic not present before describe: \" + topic\n            + \"; existing=\" + existing);\n}","typeGuard":null,"tryCatchPattern":"try {\n    int partitions = kafkaAdminManager.partitions(topic);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Topic doesn't exist:\")) {\n        // create the topic or correct the configured topic name, then retry once\n    } else {\n        throw e;\n    }\n}","preventionTips":["Create all needed topics at startup (NewTopic beans / AdminClient.createTopics) before describing them","Compare configured topic names against admin.listTopics() in a startup health check","Watch for case/whitespace differences in topic names from config properties","Allow time for Dev Services topic auto-creation before querying; the 2000ms timeout in partitions() is aggressive"],"tags":["kafka","topic","devservices","illegal-argument"],"backgroundTag":"kafka-topic-not-found","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}