{"record":{"id":"3b6148bb7cd1e018","repo":"apache/pulsar","slug":"need-to-provide-a-non-persistent-topic-name","errorCode":null,"errorMessage":"Need to provide a non-persistent topic name","messagePattern":"Need to provide a non-persistent topic name","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CliCommand.java","lineNumber":64,"sourceCode":"        return NamespaceName.get(namespace).toString();\n    }\n\n    static String validateTopicName(String topic) {\n        return TopicName.get(topic).toString();\n    }\n\n    static String validatePersistentTopic(String topic) {\n        TopicName topicName = TopicName.get(topic);\n        if (topicName.getDomain() != TopicDomain.persistent) {\n            throw new IllegalArgumentException(\"Need to provide a persistent topic name\");\n        }\n        return topicName.toString();\n    }\n\n    static String validateNonPersistentTopic(String topic) {\n        TopicName topicName = TopicName.get(topic);\n        if (topicName.getDomain() != TopicDomain.non_persistent) {\n            throw new IllegalArgumentException(\"Need to provide a non-persistent topic name\");\n        }\n        return topicName.toString();\n    }\n\n    static MessageId validateMessageIdString(String resetMessageIdStr) throws PulsarAdminException {\n        return validateMessageIdString(resetMessageIdStr, -1);\n    }\n\n    static MessageId validateMessageIdString(String resetMessageIdStr, int partitionIndex) throws PulsarAdminException {\n        String[] messageId = resetMessageIdStr.split(\":\");\n        try {\n            com.google.common.base.Preconditions.checkArgument(messageId.length == 2);\n            return new MessageIdImpl(Long.parseLong(messageId[0]), Long.parseLong(messageId[1]), partitionIndex);\n        } catch (Exception e) {\n            throw new PulsarAdminException(\n                    \"Invalid message id (must be in format: ledgerId:entryId) value \" + resetMessageIdStr);\n        }\n    }","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CliCommand.java#L46-L82","documentation":"The mirror of the persistent check: CliCommand.validateNonPersistentTopic requires the topic argument to parse to TopicDomain.non_persistent (non-persistent://tenant/namespace/topic). Any other domain (including the default persistent domain) causes an immediate IllegalArgumentException.","triggerScenarios":"Running a non-persistent-topic-only admin command with a topic name of the form persistent://tenant/namespace/topic or a short name that defaults to the persistent domain.","commonSituations":"Forgetting the non-persistent:// prefix when issuing non-persistent-specific admin commands (e.g. stats or lookups on non-persistent topics); mixing up which commands accept which domain in scripts; docs examples showing short topic names.","solutions":["Prefix the topic explicitly: non-persistent://tenant/namespace/topic","If the topic is actually persistent, use the persistent-topic command instead","Script a domain check on the topic string before invoking the CLI","Avoid short topic names in admin scripts so the domain is never defaulted unexpectedly"],"exampleFix":"// before\npulsar-admin topics stats public/default/my-topic\n// after\npulsar-admin topics stats non-persistent://public/default/my-topic","handlingStrategy":"validation","validationCode":"// Validate topic domain before invoking a non-persistent-only command\nif (!topic.startsWith(\"non-persistent://\")) {\n    throw new IllegalArgumentException(\"This command requires a non-persistent topic, got: \" + topic);\n}","typeGuard":null,"tryCatchPattern":"try {\n    admin.topics().getStats(topic);\n} catch (IllegalArgumentException e) {\n    log.error(\"{} — prefix topic with non-persistent://\", e.getMessage());\n}","preventionTips":["Explicitly write non-persistent:// in scripts rather than relying on defaults","Tag non-persistent topics clearly in configuration so the right admin command is chosen","Avoid reusing persistent-topic variables for non-persistent admin calls","Review CLI command docs to confirm which domain each command accepts"],"tags":["cli","pulsar-admin","topic-domain","argument-validation"],"backgroundTag":"invalid-topic-domain","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}