{"record":{"id":"d8cd9ca96aa970e1","repo":"apache/pulsar","slug":"need-to-specify-either-enable-or-disable","errorCode":null,"errorMessage":"Need to specify either --enable or --disable","messagePattern":"Need to specify either --enable or --disable","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java","lineNumber":622,"sourceCode":"    }\n\n    @Command(description = \"Enable or disable deduplication for a namespace\")\n    private class SetDeduplication extends CliCommand {\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Option(names = { \"--enable\", \"-e\" }, description = \"Enable deduplication\")\n        private boolean enable = false;\n\n        @Option(names = { \"--disable\", \"-d\" }, description = \"Disable deduplication\")\n        private boolean disable = false;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String namespace = validateNamespace(namespaceName);\n\n            if (enable == disable) {\n                throw new ParameterException(\"Need to specify either --enable or --disable\");\n            }\n            getAdmin().namespaces().setDeduplicationStatus(namespace, enable);\n        }\n    }\n\n    @Command(description = \"Enable or disable autoTopicCreation for a namespace, overriding broker settings\")\n    private class SetAutoTopicCreation extends CliCommand {\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Option(names = { \"--enable\", \"-e\" }, description = \"Enable allowAutoTopicCreation on namespace\")\n        private boolean enable = false;\n\n        @Option(names = { \"--disable\", \"-d\" }, description = \"Disable allowAutoTopicCreation on namespace\")\n        private boolean disable = false;\n\n        @Option(names = { \"--type\", \"-t\" }, description = \"Type of topic to be auto-created. \"\n                + \"Possible values: (partitioned, non-partitioned). Default value: non-partitioned\")","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java#L604-L640","documentation":"Thrown by the set-deduplication-status command when neither or both of --enable and --disable were specified. The pair must be mutually exclusive and exactly one must be present; `enable == disable` catches the ambiguous case (both false or both true) before calling setDeduplicationStatus.","triggerScenarios":"Running `pulsar-admin namespaces set-deduplication <ns>` with neither flag, with both flags, or with both flags defaulting to false because the command uses JCommander boolean flags whose defaults make them equal.","commonSituations":"Forgetting the flag entirely in a script; templating that injects both flags; assuming a positional on/off argument instead of a flag; older CLI examples using a different flag name.","solutions":["Pass exactly one flag: --enable to turn deduplication on, --disable to turn it off","Remove any duplicate/contradictory flag in the scripted command line","Check templated commands so only one of the two flags is rendered","Run with --help to confirm the flag names for your CLI version"],"exampleFix":"// before\npulsar-admin namespaces set-deduplication my-tenant/ns\n// after\npulsar-admin namespaces set-deduplication my-tenant/ns --enable","handlingStrategy":"validation","validationCode":"count=0; [[ $ENABLE == true ]] && count=$((count+1)); [[ $DISABLE == true ]] && count=$((count+1))\n[ $count -eq 1 ] || { echo \"specify exactly one of --enable/--disable\"; exit 1; }","typeGuard":null,"tryCatchPattern":"try { ... } catch (ParameterException e) { /* ambiguous flags: pass exactly one of --enable/--disable */ }","preventionTips":["Always pass exactly one of --enable or --disable","Audit generated/templated command lines for duplicate flags","Default scripts to --disable explicitly rather than omitting the flag"],"tags":["cli","argument-validation","flags","deduplication","pulsar-admin"],"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-14T05:17:10.506Z"}