{"record":{"id":"9c92d31d3cb46427","repo":"apache/pulsar","slug":"need-to-specify-either-enable-or-disable-9c92d3","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/CmdTopics.java","lineNumber":1730,"sourceCode":"        @Option(names = { \"--disable\", \"-d\" }, description = \"Disable delayed delivery messages\")\n        private boolean disable = false;\n\n        @Option(names = { \"--time\", \"-t\" },\n                description = \"The tick time for when retrying on delayed delivery messages, affecting the accuracy of \"\n                        + \"the delivery time compared to the scheduled time. (eg: 1s, 10s, 1m, 5h, 3d)\",\n                converter = TimeUnitToMillisConverter.class)\n        private Long delayedDeliveryTimeInMills = 1_000L;\n\n        @Option(names = {\"--maxDelay\", \"-md\"},\n                description = \"The max allowed delay for delayed delivery. (eg: 1s, 10s, 1m, 5h, 3d)\",\n                converter = TimeUnitToMillisConverter.class)\n        private Long delayedDeliveryMaxDelayInMillis = 0L;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String topic = validateTopicName(topicName);\n            if (enable == disable) {\n                throw new ParameterException(\"Need to specify either --enable or --disable\");\n            }\n\n            getTopics().setDelayedDeliveryPolicy(topic, DelayedDeliveryPolicies.builder()\n                    .tickTime(delayedDeliveryTimeInMills)\n                    .active(enable)\n                    .maxDeliveryDelayInMillis(delayedDeliveryMaxDelayInMillis)\n                    .build());\n        }\n    }\n\n    @Command(description = \"Remove the delayed delivery policy on a topic\", hidden = true)\n    private class RemoveDelayedDelivery extends CliCommand {\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topic;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String topicName = validateTopicName(topic);","sourceCodeStart":1712,"sourceCodeEnd":1748,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java#L1712-L1748","documentation":"CmdTopics' SetDelayedDelivery command requires exactly one of the mutually exclusive flags --enable or --disable. The command throws this ParameterException when `enable == disable`, i.e. both flags were set to the same state (both true, both false, or neither provided). It is a CLI argument-validation guard before calling setDelayedDeliveryPolicy.","triggerScenarios":"Running `pulsar-admin topics set-delayed-delivery <topic>` with neither --enable nor --disable, or with both flags supplied, or with `--enable=false --disable=false` such that the parsed booleans are equal.","commonSituations":"Scripting the command from a variable that expands to an empty flag; copying an old command line where the flag was renamed; assuming delayed delivery is enabled by default and omitting the flag.","solutions":["Pass exactly one of --enable or --disable, e.g. `pulsar-admin topics set-delayed-delivery <topic> --enable`.","If scripting, ensure the flag variable expands to exactly one value and is not empty.","Use `pulsar-admin topics get-delayed-delivery <topic>` first to check the current policy before toggling."],"exampleFix":"// before (no flag)\nbin/pulsar-admin topics set-delayed-delivery persistent://public/default/my-topic\n// after\nbin/pulsar-admin topics set-delayed-delivery persistent://public/default/my-topic --enable","handlingStrategy":"validation","validationCode":"// shell validation before invoking the CLI\nif [ \"$ENABLE_FLAG\" != \"--enable\" ] && [ \"$ENABLE_FLAG\" != \"--disable\" ]; then\n  echo \"must pass exactly one of --enable or --disable\"; exit 1;\nfi\nbin/pulsar-admin topics set-delayed-delivery \"$TOPIC\" \"$ENABLE_FLAG\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair set-delayed-delivery with exactly one boolean flag.","In scripts, default the flag to --enable or --disable explicitly rather than leaving it empty.","Lint command templates so empty shell variables fail fast."],"tags":["cli","argument-validation","pulsar-admin"],"backgroundTag":"missing-required-cli-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"}