{"record":{"id":"1316b5ff156bd08b","repo":"apache/pulsar","slug":"need-to-specify-either-enable-or-disable-1316b5","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/CmdTopicPolicies.java","lineNumber":792,"sourceCode":"                + \"delayed delivery messages, affecting the accuracy of the delivery time compared to \"\n                + \"the scheduled time. (eg: 1s, 10s, 1m, 5h, 3d)\",\n                converter = TimeUnitToMillisConverter.class)\n        private Long delayedDeliveryTimeInMills = 1000L;\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;\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            getTopicPolicies(isGlobal).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\")\n    private class RemoveDelayedDelivery extends CliCommand {\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topicName;\n\n        @Option(names = { \"--global\", \"-g\" }, description = \"Whether to remove this policy globally. \"\n                + \"If set to true, the policy will be replicate to other clusters asynchronously\")\n        private boolean isGlobal;","sourceCodeStart":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java#L774-L810","documentation":"Thrown by the set-delayed-delivery command when the --enable and --disable flags end up equal (both false or both true), so the desired policy state is ambiguous. The command requires exactly one of the two flags to be set to set the delayed delivery policy's active flag.","triggerScenarios":"Running `pulsar-admin topics set-delayed-delivery` with neither --enable nor --disable, or (in some flag-parsing setups) both flags provided so they cancel out to equal values.","commonSituations":"Omitting the flag entirely, scripting where a boolean variable is neither converted to --enable nor --disable, or accidentally passing the flag twice (e.g. --enable --disable).","solutions":["Add exactly one of --enable or --disable to the command","If both are passed, remove one so they differ","Fix the script so the boolean maps to exactly one flag"],"exampleFix":"// before\npulsar-admin topics set-delayed-delivery --tick-time 1000 -t my-topic\n// after\npulsar-admin topics set-delayed-delivery --enable --tick-time 1000 -t my-topic","handlingStrategy":"validation","validationCode":"if (enable == disable) {\n    throw new IllegalArgumentException(\"Pass exactly one of --enable or --disable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    admin.topicPolicies().setDelayedDeliveryPolicy(topic, policy);\n} catch (ParameterException e) {\n    System.err.println(\"Specify exactly one of --enable/--disable\");\n}","preventionTips":["Always pair set-delayed-delivery with exactly one flag","In scripts, map booleans to one flag via if/else, not parameter expansion","Double-check copy-pasted commands for duplicated flags"],"tags":["pulsar-admin","cli","topic-policies","missing-flag"],"backgroundTag":"mutually-exclusive-options-missing","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"}