{"record":{"id":"b7a2043eac3c26a0","repo":"apache/pulsar","slug":"does-not-support-topic-domain","errorCode":null,"errorMessage":"Does not support topic domain: ","messagePattern":"Does not support topic domain: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-common/src/main/java/org/apache/pulsar/common/topics/TopicList.java","lineNumber":128,"sourceCode":"        s1.removeAll(list2);\n        return s1;\n    }\n\n    public static String removeTopicDomainScheme(String originalRegexp) {\n        if (!originalRegexp.toString().contains(SCHEME_SEPARATOR)) {\n            return originalRegexp;\n        }\n        String[] parts = SCHEME_SEPARATOR_PATTERN.split(originalRegexp.toString());\n        String prefix = parts[0];\n        String removedTopicDomain = parts[1];\n        if (prefix.equals(TopicDomain.persistent.value()) || prefix.equals(TopicDomain.non_persistent.value())) {\n            prefix = \"\";\n        } else if (prefix.endsWith(TopicDomain.non_persistent.value())) {\n            prefix = prefix.substring(0, prefix.length() - TopicDomain.non_persistent.value().length());\n        } else if (prefix.endsWith(TopicDomain.persistent.value())){\n            prefix = prefix.substring(0, prefix.length() - TopicDomain.persistent.value().length());\n        } else {\n            throw new IllegalArgumentException(\"Does not support topic domain: \" + prefix);\n        }\n        return prefix + removedTopicDomain;\n    }\n}\n","sourceCodeStart":110,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-common/src/main/java/org/apache/pulsar/common/topics/TopicList.java#L110-L133","documentation":"Thrown by TopicList.removeTopicDomainScheme when the given string prefix does not end with a recognized topic domain ('persistent' or 'non-persistent') and is not empty. The method can only strip a topic domain scheme it knows; any other ending prefix is rejected with this IllegalArgumentException.","triggerScenarios":"Calling removeTopicDomainScheme with a topic string or prefix that does not end in 'persistent/' or 'non-persistent/' — e.g. a plain topic name without a domain, a typo like 'persistant://', or a namespace-only string.","commonSituations":"Passing already-domain-stripped topics back into the function (double stripping); user-supplied topic lists mixing domainful and domain-less names; case mismatches ('Persistent://'); partitions or REST paths that omit the domain; custom tooling building topic names by hand.","solutions":["Only call removeTopicDomainScheme on strings that include the 'persistent://' or 'non-persistent://' scheme","Check/normalize the input first (endsWith check or TopicName validation) and skip stripping when no domain is present","Fix typos and casing in the domain portion before calling","Handle domain-less topics separately instead of routing them through this method"],"exampleFix":"// before\nString name = TopicList.removeTopicDomainScheme(topic); // topic = \"my-tenant/ns/my-topic\"\n// after\nString name = topic.startsWith(\"persistent://\") || topic.startsWith(\"non-persistent://\")\n        ? TopicList.removeTopicDomainScheme(topic)\n        : topic;","handlingStrategy":"validation","validationCode":"if (topic.startsWith(\"persistent://\") || topic.startsWith(\"non-persistent://\")) {\n    String stripped = TopicList.removeTopicDomainScheme(topic);\n}","typeGuard":"static boolean hasTopicDomain(String topic) {\n    return topic != null && (topic.startsWith(\"persistent://\") || topic.startsWith(\"non-persistent://\"));\n}","tryCatchPattern":"try {\n    stripped = TopicList.removeTopicDomainScheme(topic);\n} catch (IllegalArgumentException e) {\n    stripped = topic; // treat as already domain-less\n}","preventionTips":["Only strip the domain once — track whether it was already removed","Normalize casing before calling (domains are lowercase)","Validate topics with TopicName or regex before processing lists","Never pass namespace-only or bare topic names into removeTopicDomainScheme"],"tags":["parsing","validation","topics"],"backgroundTag":"unsupported-topic-domain","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}