{"record":{"id":"fd69a6a14dacd34a","repo":"apache/pulsar","slug":"illegal-subscription-type-s-possible-values-s-fd69a6","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/CmdTopicPolicies.java","lineNumber":478,"sourceCode":"\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        @Option(names = { \"--global\", \"-g\" }, description = \"Whether to get this policy globally. \"\n                + \"If set to true, broker returned global topic policies\")\n        private boolean isGlobal = false;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String persistentTopic = validatePersistentTopic(topicName);\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            getTopicPolicies(isGlobal).setSubscriptionTypesEnabled(persistentTopic, types);\n        }\n    }\n\n    @Command(description = \"Get subscription types enabled for a topic\")\n    private class GetSubscriptionTypesEnabled extends CliCommand {\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topicName;\n\n        @Option(names = { \"--global\", \"-g\" }, description = \"Whether to set this policy globally. \"\n                + \"If set to true, the policy will be replicate to other clusters asynchronously\")\n        private boolean isGlobal = false;\n\n        @Override","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java#L460-L496","documentation":"Thrown while setting the subscriptionTypesEnabled topic policy: one of the comma-separated values passed to the subscription-types option cannot be parsed as a SubscriptionType enum constant. Pulsar validates the token with SubscriptionType.valueOf and converts any parse failure into this ParameterException listing all legal values.","triggerScenarios":"Running `pulsar-admin topics set-subscription-types-enabled` with a type string that is not an exact enum constant, e.g. 'shared' instead of 'Shared', 'non-durable' instead of 'NonDurable', or an unknown value.","commonSituations":"Case mismatch (enum constants are capitalized), using hyphenated or lowercase spellings, listing a type that does not exist in the broker's Pulsar version, or extra whitespace/typos in the comma-separated list.","solutions":["Use exact enum values: Exclusive, Shared, Failover, Key_Shared (as applicable to your version)","Match capitalization exactly — valueOf is case-sensitive","Remove whitespace or stray characters from the comma-separated list","Upgrade the client/broker if the desired subscription type does not exist in this version"],"exampleFix":"// before\n--subscription-types shared,failover\n// after\n--subscription-types Shared,Failover","handlingStrategy":"validation","validationCode":"for (String s : subTypes) {\n    SubscriptionType.valueOf(s); // throws IllegalArgumentException listing valid constants\n}","typeGuard":"boolean isKnownSubscriptionType(String s) {\n    for (SubscriptionType t : SubscriptionType.values()) {\n        if (t.name().equals(s)) return true;\n    }\n    return false;\n}","tryCatchPattern":"try {\n    admin.topicPolicies().setSubscriptionTypesEnabled(topic, types);\n} catch (IllegalArgumentException e) {\n    System.err.println(\"Valid: \" + Arrays.toString(SubscriptionType.values()));\n}","preventionTips":["Use exact capitalized enum names: Shared, Failover, Key_Shared, Exclusive","Never hyphenate or lowercase the type tokens","Trim each token when splitting a comma-separated list","Confirm the type exists in your broker's Pulsar version"],"tags":["pulsar-admin","cli","topic-policies","invalid-enum-value"],"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"}