{"record":{"id":"0330a6a6b151b7ba","repo":"apache/pulsar","slug":"illegal-subscription-type-s-possible-values-s","errorCode":null,"errorMessage":"Illegal subscription type %s. Possible values: %s.","messagePattern":"Illegal subscription type (.+?)\\. Possible values: (.+?)\\.","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java","lineNumber":353,"sourceCode":"    @Command(description = \"Set subscription types enabled for a namespace\")\n    private class SetSubscriptionTypesEnabled extends CliCommand {\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Option(names = {\"--types\", \"-t\"}, description = \"Subscription types enabled list (comma separated values).\"\n                + \" Possible values: (Exclusive, Shared, Failover, Key_Shared).\", required = true, split = \",\")\n        private List<String> subTypes;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String namespace = validateNamespace(namespaceName);\n            Set<SubscriptionType> types = new HashSet<>();\n            subTypes.forEach(s -> {\n                SubscriptionType subType;\n                try {\n                    subType = SubscriptionType.valueOf(s);\n                } catch (IllegalArgumentException exception) {\n                    throw new ParameterException(String.format(\"Illegal subscription type %s. Possible values: %s.\", s,\n                            Arrays.toString(SubscriptionType.values())));\n                }\n                types.add(subType);\n            });\n            getAdmin().namespaces().setSubscriptionTypesEnabled(namespace, types);\n        }\n    }\n\n    @Command(description = \"Get subscription types enabled for a namespace\")\n    private class GetSubscriptionTypesEnabled extends CliCommand {\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String namespace = validateNamespace(namespaceName);\n            print(getAdmin().namespaces().getSubscriptionTypesEnabled(namespace));\n        }","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java#L335-L371","documentation":"Thrown when a --sub-type value passed to the set-subscription-types-enabled command cannot be resolved to a pulsar.common.util.SubscriptionType enum constant via valueOf. The message lists all legal values so the caller can correct the input.","triggerScenarios":"Running `pulsar-admin namespaces set-subscription-types-enabled <ns> --sub-type` with an invalid name such as 'Exclusive', 'shared' in wrong case, or a typo like 'Failovered'. Only enum constants of SubscriptionType (e.g. Exclusive, Shared, Failover, Key_Shared) are accepted.","commonSituations":"Lowercasing enum names in scripts ('shared' instead of 'Shared'); using documentation terms like 'non-durable' which are not SubscriptionType constants; version drift where a type like Key_Shared doesn't exist in older clients; multiple values separated incorrectly.","solutions":["Use exact enum names: SubscriptionType.values() shows them, e.g. --sub-type Shared --sub-type Failover --sub-type Key_Shared","Match case exactly (valueOf is case-sensitive)","Repeat the --sub-type flag once per type instead of comma-joining","Check SubscriptionType constants for your Pulsar version (Key_Shared requires a recent version)"],"exampleFix":"// before\npulsar-admin namespaces set-subscription-types-enabled t/ns --sub-type shared\n// after\npulsar-admin namespaces set-subscription-types-enabled t/ns --sub-type Shared --sub-type Failover","handlingStrategy":"validation","validationCode":"VALID='Exclusive Shared Failover Key_Shared'\nfor t in $SUB_TYPES; do [[ \" $VALID \" == *\" $t \"* ]] || { echo \"illegal subscription type: $t\"; exit 1; }; done","typeGuard":"// Java\nboolean isValidSubType(String s) {\n    for (SubscriptionType t : SubscriptionType.values()) {\n        if (t.name().equals(s)) return true;\n    }\n    return false;\n}","tryCatchPattern":"try { ... } catch (ParameterException e) { /* bad enum name: use exact SubscriptionType names */ }","preventionTips":["Use exact case-sensitive enum names (Shared, not shared)","Repeat --sub-type per value instead of comma-joining","Confirm Key_Shared exists in your Pulsar version"],"tags":["cli","argument-validation","enum","subscription","pulsar-admin"],"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"}