{"record":{"id":"71fbcfb2ba90c804","repo":"apache/pulsar","slug":"invalid-interval-d-71fbcf","errorCode":null,"errorMessage":"Invalid interval '%d'. ","messagePattern":"Invalid interval '(.+?)'\\. ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java","lineNumber":1823,"sourceCode":"        void run() throws PulsarAdminException {\n            String persistentTopic = validatePersistentTopic(topicName);\n            print(getTopics().getDeduplicationSnapshotInterval(persistentTopic));\n        }\n    }\n\n    @Command(description = \"Set deduplication snapshot interval for a topic\", hidden = true)\n    private class SetDeduplicationSnapshotInterval extends CliCommand {\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topicName;\n\n        @Option(names = { \"-i\", \"--interval\" }, description = \"Deduplication snapshot interval for topic in second, \"\n                + \"allowed range from 0 to Integer.MAX_VALUE\", required = true)\n        private int interval;\n\n        @Override\n        void run() throws PulsarAdminException {\n            if (interval < 0) {\n                throw new IllegalArgumentException(String.format(\"Invalid interval '%d'. \", interval));\n            }\n\n            String persistentTopic = validatePersistentTopic(topicName);\n            getTopics().setDeduplicationSnapshotInterval(persistentTopic, interval);\n        }\n    }\n\n    @Command(description = \"Remove deduplication snapshot interval for a topic\", hidden = true)\n    private class RemoveDeduplicationSnapshotInterval extends CliCommand {\n\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topicName;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String persistentTopic = validatePersistentTopic(topicName);\n            getTopics().removeDeduplicationSnapshotInterval(persistentTopic);\n        }","sourceCodeStart":1805,"sourceCodeEnd":1841,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java#L1805-L1841","documentation":"The SetDeduplicationSnapshotInterval command validates that the required --interval parameter is non-negative before calling setDeduplicationSnapshotInterval. A negative value throws IllegalArgumentException with the invalid value formatted into the message; the documented valid range is 0 to Integer.MAX_VALUE.","triggerScenarios":"Running `pulsar-admin topics set-deduplication-snapshot-interval <topic> --interval -N` where N > 0.","commonSituations":"Deriving the interval from a config value or subtraction that goes negative; typo like `--interval -1` while intending to unset the value.","solutions":["Pass a non-negative interval, e.g. `--interval 1000` (milliseconds).","Use 0 to effectively disable deduplication snapshotting rather than a negative number.","To unset the policy entirely, use the remove-deduplication-snapshot-interval command instead of a negative value."],"exampleFix":"// before\nbin/pulsar-admin topics set-deduplication-snapshot-interval my-topic --interval -1\n// after\nbin/pulsar-admin topics set-deduplication-snapshot-interval my-topic --interval 1000","handlingStrategy":"validation","validationCode":"// validate before invoking\nINTERVAL=$((INTERVAL + 0))\nif [ \"$INTERVAL\" -lt 0 ]; then echo \"interval must be >= 0\"; exit 1; fi\nbin/pulsar-admin topics set-deduplication-snapshot-interval \"$TOPIC\" --interval \"$INTERVAL\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp computed intervals to >= 0 before calling the CLI.","Remember 0 is the valid 'disabled' value, not a negative number.","Use remove commands to clear policies rather than negative sentinels."],"tags":["cli","argument-validation","range-check"],"backgroundTag":"invalid-argument-value","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"}