{"record":{"id":"e9349af66103deed","repo":"apache/pulsar","slug":"if-you-want-to-clear-the-properties-you-have-to-us","errorCode":null,"errorMessage":"If you want to clear the properties you have to use --clear","messagePattern":"If you want to clear the properties you have to use --clear","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java","lineNumber":987,"sourceCode":"                \"--subscription\" }, description = \"Subscription to update\", required = true)\n        private String subscriptionName;\n\n        @Option(names = {\"--property\", \"-p\"}, description = \"key value pair properties(-p a=b -p c=d)\",\n                required = false)\n        private Map<String, String> properties;\n\n        @Option(names = {\"--clear\", \"-c\"}, description = \"Remove all properties\",\n                required = false)\n        private boolean clear;\n\n        @Override\n        void run() throws Exception {\n            String topic = validateTopicName(topicName);\n            if (properties == null) {\n                properties = Collections.emptyMap();\n            }\n            if ((properties.isEmpty()) && !clear) {\n                throw new IllegalArgumentException(\"If you want to clear the properties you have to use --clear\");\n            }\n            if (clear && !properties.isEmpty()) {\n                throw new IllegalArgumentException(\"If you set --clear then you should not pass any properties\");\n            }\n            getTopics().updateSubscriptionProperties(topic, subscriptionName, properties);\n        }\n    }\n\n    @Command(description = \"Get the properties of a subscription on a topic\")\n    private class GetSubscriptionProperties extends CliCommand {\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topicName;\n\n        @Option(names = { \"-s\",\n                \"--subscription\" }, description = \"Subscription to describe\", required = true)\n        private String subscriptionName;\n\n        @Override","sourceCodeStart":969,"sourceCodeEnd":1005,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java#L969-L1005","documentation":"The update-subscription-properties command requires that clearing all properties be explicit. If the resulting properties map is empty and --clear was not passed, the command throws IllegalArgumentException, since passing no properties without --clear is ambiguous (a no-op vs. clearing).","triggerScenarios":"Running `pulsar-admin topics update-subscription-properties <topic> -s <sub>` with no --properties and without --clear, so properties.isEmpty() && !clear.","commonSituations":"Users wanting to wipe all subscription properties but forgetting the --clear flag; scripts passing an empty properties list; copy-pasted commands stripped of the --properties argument.","solutions":["Add --clear when you intend to remove all subscription properties","Or supply at least one key=value via --properties if you meant to set properties","If a no-op was intended, add --clear to satisfy validation or skip running the command"],"exampleFix":"// before\npulsar-admin topics update-subscription-properties my-topic -s sub1\n// after\npulsar-admin topics update-subscription-properties my-topic -s sub1 --clear","handlingStrategy":"validation","validationCode":"if ((properties == null || properties.isEmpty()) && !clear) {\n    throw new IllegalArgumentException(\"Pass --clear to wipe subscription properties\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    admin.topics().updateSubscriptionProperties(topic, sub, props);\n} catch (IllegalArgumentException e) {\n    log.error(\"Use --clear to remove all subscription properties\", e);\n}","preventionTips":["Add --clear whenever you intend to remove all properties","Don't run update-subscription-properties with no arguments expecting a no-op","Explicitly pass the properties you want to keep/set"],"tags":["cli","parameter-validation","subscription-properties"],"backgroundTag":"missing-required-flag","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"}