{"record":{"id":"dd9f150b9840f9b7","repo":"apache/pulsar","slug":"if-you-set-clear-then-you-should-not-pass-any-pr","errorCode":null,"errorMessage":"If you set --clear then you should not pass any properties","messagePattern":"If you set --clear then you should not pass any properties","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java","lineNumber":990,"sourceCode":"        @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\n        void run() throws Exception {\n            String topic = validateTopicName(topicName);\n            Map<String, String> result = getTopics().getSubscriptionProperties(topic, subscriptionName);","sourceCodeStart":972,"sourceCodeEnd":1008,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java#L972-L1008","documentation":"Mutually-exclusive-options guard in CmdTopics property update: --clear (remove all properties) was combined with explicit -p/--property pairs, which is ambiguous, so the command refuses to run until one of the two is dropped.","triggerScenarios":"Running `pulsar-admin topics update-subscription-properties <topic> -s <sub> --clear --properties k=v` — clear is true and the properties map is non-empty.","commonSituations":"Users wanting to 'reset then set' properties in one call; scripts merging flags where --clear is always appended; misunderstanding that --clear is exclusive, not a precursor.","solutions":["Use either --clear or a property list, not both"],"exampleFix":"// before\npulsar-admin topics update-subscription-properties my-topic -s sub1 --clear --properties env=prod\n// after\npulsar-admin topics update-subscription-properties my-topic -s sub1 --properties env=prod","handlingStrategy":"validation","validationCode":"if (clear && properties != null && !properties.isEmpty()) {\n    throw new IllegalArgumentException(\"--clear cannot be combined with --properties\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    admin.topics().updateSubscriptionProperties(topic, sub, props);\n} catch (IllegalArgumentException e) {\n    log.error(\"--clear is exclusive; drop it or drop --properties\", e);\n}","preventionTips":["Treat --clear as mutually exclusive with --properties","To replace properties, pass the new set without --clear (they overwrite)","Split wipe-then-set into two command invocations if needed"],"tags":["cli","parameter-validation","mutually-exclusive-flags"],"backgroundTag":"mutually-exclusive-arguments","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"}