{"record":{"id":"6785a41e05269e21","repo":"apache/pulsar","slug":"invalid-topic-domain-value","errorCode":null,"errorMessage":"Invalid topic domain: '${value}'","messagePattern":"Invalid topic domain: '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/naming/TopicDomain.java","lineNumber":44,"sourceCode":"    topic(\"topic\"), segment(\"segment\");\n\n    private String value;\n\n    private TopicDomain(String value) {\n        this.value = value;\n    }\n\n    public String value() {\n        return this.value;\n    }\n\n    public static TopicDomain getEnum(String value) {\n        for (TopicDomain e : values()) {\n            if (e.value.equalsIgnoreCase(value)) {\n                return e;\n            }\n        }\n        throw new IllegalArgumentException(\"Invalid topic domain: '\" + value + \"'\");\n    }\n\n    @Override\n    public String toString() {\n        return this.value;\n    }\n}","sourceCodeStart":26,"sourceCodeEnd":51,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/naming/TopicDomain.java#L26-L51","documentation":"TopicDomain.getEnum converts a string ('persistent' or 'non-persistent', case-insensitive) into the TopicDomain enum and throws IllegalArgumentException for any other value. The library restricts topic domains to its known enum values.","triggerScenarios":"Calling TopicDomain.getEnum(value) with anything other than 'persistent' or 'non-persistent' — e.g. building a TopicName from a user-supplied or config-supplied domain string.","commonSituations":"Typos like 'persistant', using 'persistent://...' parsing with a mangled scheme, dynamic topic URLs from user input containing unexpected domains, or future/unknown domain values from newer clients.","solutions":["Use TopicDomain.persistent.value() (or the enum constant) instead of hand-writing the domain string","Validate the domain string against the allowed values before calling getEnum","Normalize user input (trim, lowercase) and reject unknown values with a clear message"],"exampleFix":"// before\nTopicDomain domain = TopicDomain.getEnum(userInput);\n// after\nif (!\"persistent\".equalsIgnoreCase(userInput) && !\"non-persistent\".equalsIgnoreCase(userInput)) {\n    throw new IllegalArgumentException(\"domain must be persistent or non-persistent\");\n}\nTopicDomain domain = TopicDomain.getEnum(userInput.trim());","handlingStrategy":"validation","validationCode":"boolean isValidTopicDomain(String v) {\n    return \"persistent\".equalsIgnoreCase(v) || \"non-persistent\".equalsIgnoreCase(v);\n}","typeGuard":null,"tryCatchPattern":"try {\n    TopicDomain d = TopicDomain.getEnum(value);\n} catch (IllegalArgumentException e) {\n    throw new IllegalArgumentException(\"topic domain must be persistent|non-persistent: \" + value);\n}","preventionTips":["Use TopicDomain enum constants instead of raw strings","Normalize (trim/lowercase) user-provided topic URLs","Whitelist domains at the input boundary"],"tags":["enum","parsing","illegal-argument"],"backgroundTag":"invalid-enum-value","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"}