{"record":{"id":"4c15503445e87113","repo":"apache/pulsar","slug":"delete-mode-can-only-be-set-to-delete-when-no-subs","errorCode":null,"errorMessage":"delete mode can only be set to delete_when_no_subscriptions or delete_when_subscriptions_caught_up","messagePattern":"delete mode can only be set to delete_when_no_subscriptions or delete_when_subscriptions_caught_up","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java","lineNumber":1601,"sourceCode":"                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        @Override\n        void run() throws PulsarAdminException {\n            String namespace = validateNamespace(namespaceName);\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 = null;\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            getAdmin().namespaces().setInactiveTopicPolicies(namespace, new InactiveTopicPolicies(deleteMode,\n                    maxInactiveDurationInSeconds.intValue(), enableDeleteWhileInactive));\n        }\n    }\n\n    @Command(description = \"Set the delayed delivery policy on a namespace\")\n    private class SetDelayedDelivery extends CliCommand {\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Option(names = { \"--enable\", \"-e\" }, description = \"Enable delayed delivery messages\")\n        private boolean enable = false;\n\n        @Option(names = { \"--disable\", \"-d\" }, description = \"Disable delayed delivery messages\")\n        private boolean disable = false;\n","sourceCodeStart":1583,"sourceCodeEnd":1619,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java#L1583-L1619","documentation":"Thrown by 'set-inactive-topic-policies' when the value passed to the inactive-topic-delete-mode flag is not a valid InactiveTopicDeleteMode enum constant. The code does InactiveTopicDeleteMode.valueOf(...) and converts the resulting IllegalArgumentException into this ParameterException, listing the only accepted values: delete_when_no_subscriptions or delete_when_subscriptions_caught_up. It is a client-side value validation before any admin call.","triggerScenarios":"Passing an unknown/misspelled delete mode string (e.g. 'deleteWhenNoSubscriptions', 'delete_when_subscription_caught_up', 'none') to the delete-mode flag of set-inactive-topic-policies.","commonSituations":"Case mismatch (camelCase vs SCREAMING_SNAKE); hand-editing scripts with a guessed enum name; docs/versions drift where an old or hypothetical mode value is used.","solutions":["Use exactly one of the accepted values: delete_when_no_subscriptions or delete_when_subscriptions_caught_up (all lowercase).","Check the enum spelling with the values shown in this message or 'pulsar-admin namespaces set-inactive-topic-policies --help'.","Fix shell variables so an empty/undefined value is not expanded into the flag."],"exampleFix":"// before\npulsar-admin namespaces set-inactive-topic-policies public/default --enable-delete-while-inactive --deleteWhenNoSubscriptions --max-inactive-duration 30\n// after\npulsar-admin namespaces set-inactive-topic-policies public/default --enable-delete-while-inactive --delete_when_no_subscriptions --max-inactive-duration 30","handlingStrategy":"validation","validationCode":"MODE=\"$1\"\ncase \"$MODE\" in\n  delete_when_no_subscriptions|delete_when_subscriptions_caught_up) ;;\n  *) echo \"invalid delete mode: $MODE\"; exit 1;;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exact lowercase enum values: delete_when_no_subscriptions or delete_when_subscriptions_caught_up.","Never camelCase or abbreviate the mode.","Source values from the error's possible-values list, not memory."],"tags":["cli","enum-value","pulsar-admin"],"backgroundTag":"invalid-enum-value","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"}