{"record":{"id":"c1bb488dde098523","repo":"apache/pulsar","slug":"need-to-specify-either-enable-delete-while-inactiv-c1bb48","errorCode":null,"errorMessage":"Need to specify either enable-delete-while-inactive or disable-delete-while-inactive","messagePattern":"Need to specify either enable-delete-while-inactive or disable-delete-while-inactive","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java","lineNumber":1480,"sourceCode":"        @Option(names = {\"--max-inactive-duration\", \"-t\"},\n                description = \"Max duration of topic inactivity in seconds, topics that are inactive for longer than \"\n                        + \"this value will be deleted (eg: 1s, 10s, 1m, 5h, 3d)\", required = true,\n                converter = TimeUnitToSecondsConverter.class)\n        private Long maxInactiveDurationInSeconds;\n\n        @Option(names = { \"--delete-mode\", \"-m\" }, description = \"Mode of delete inactive topic, Valid options are: \"\n                + \"[delete_when_no_subscriptions, delete_when_subscriptions_caught_up]\", required = true)\n        private String inactiveTopicDeleteMode;\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 = false;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String persistentTopic = validatePersistentTopic(topicName);\n            if (enableDeleteWhileInactive == disableDeleteWhileInactive) {\n                throw new ParameterException(\"Need to specify either enable-delete-while-inactive or \"\n                        + \"disable-delete-while-inactive\");\n            }\n            InactiveTopicDeleteMode deleteMode;\n            try {\n                deleteMode = InactiveTopicDeleteMode.valueOf(inactiveTopicDeleteMode);\n            } catch (IllegalArgumentException e) {\n                throw new ParameterException(\"delete mode can only be set to delete_when_no_subscriptions or \"\n                        + \"delete_when_subscriptions_caught_up\");\n            }\n            getTopicPolicies(isGlobal).setInactiveTopicPolicies(persistentTopic, new InactiveTopicPolicies(deleteMode,\n                    maxInactiveDurationInSeconds.intValue(), enableDeleteWhileInactive));\n        }\n    }\n\n    @Command(description = \"Remove inactive topic policies from a topic\")\n    private class RemoveInactiveTopicPolicies extends CliCommand {\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topicName;","sourceCodeStart":1462,"sourceCodeEnd":1498,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java#L1462-L1498","documentation":"The set-inactive-topic-policies command requires an explicit direction for the delete-while-inactive feature: exactly one of --enable-delete-while-inactive or --disable-delete-while-inactive must be given. Because both flags default to false, passing neither (or somehow both) makes them equal and triggers this ParameterException.","triggerScenarios":"Running set-inactive-topic-policies without either the enable or disable flag, or (if flags are set as exclusive booleans) passing both enable and disable together so enableDeleteWhileInactive == disableDeleteWhileInactive evaluates true.","commonSituations":"Scripts omitting the flag because an older CLI version did not require it; users assuming the command only updates maxInactiveDurationInSeconds and leaves the enabled state untouched; template scripts with placeholder flags never filled in.","solutions":["Add exactly one of --enable-delete-while-inactive or --disable-delete-while-inactive to the command","If you only want to change maxInactiveDurationInSeconds, still pass the flag matching the current desired enabled/disabled state"],"exampleFix":"// before\npulsar-admin topics set-inactive-topic-policies my-topic --delete-mode delete_when_no_subscriptions --max-inactive-duration 3600\n// after\npulsar-admin topics set-inactive-topic-policies my-topic --delete-mode delete_when_no_subscriptions --max-inactive-duration 3600 --enable-delete-while-inactive","handlingStrategy":"validation","validationCode":"boolean enable = flags.contains(\"--enable-delete-while-inactive\");\nboolean disable = flags.contains(\"--disable-delete-while-inactive\");\nif (enable == disable) throw new IllegalArgumentException(\"pass exactly one of enable/disable-delete-while-inactive\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the enable/disable flag even when only changing duration","Build wrappers that require an explicit enabled=true/false parameter","Check flag defaults in --help before scripting"],"tags":["cli","pulsar-admin","missing-argument","inactive-topic-policies"],"backgroundTag":"missing-required-argument","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"}