{"record":{"id":"94cf831cd0d38b0b","repo":"apache/pulsar","slug":"invalid-interval-d","errorCode":null,"errorMessage":"Invalid interval '%d'. ","messagePattern":"Invalid interval '(.+?)'\\. ","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java","lineNumber":973,"sourceCode":"    }\n\n    @Command(description = \"Set deduplication snapshot interval for a topic\")\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 =\n                \"Deduplication snapshot interval for topic in second, allowed range from 0 to Integer.MAX_VALUE\",\n                required = true)\n        private int interval;\n\n        @Option(names = {\"--global\", \"-g\"}, description = \"Whether to set this policy globally.\")\n        private boolean isGlobal = false;\n\n        @Override\n        void run() throws PulsarAdminException {\n            if (interval < 0) {\n                throw new ParameterException(String.format(\"Invalid interval '%d'. \", interval));\n            }\n\n            String persistentTopic = validatePersistentTopic(topicName);\n            getTopicPolicies(isGlobal).setDeduplicationSnapshotInterval(persistentTopic, interval);\n        }\n    }\n\n    @Command(description = \"Remove deduplication snapshot interval for a topic\")\n    private class RemoveDeduplicationSnapshotInterval extends CliCommand {\n\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        private boolean isGlobal = false;\n\n        @Override\n        void run() throws PulsarAdminException {","sourceCodeStart":955,"sourceCodeEnd":991,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java#L955-L991","documentation":"Thrown by the set-deduplication-snapshot-interval command when the --interval value is negative. The snapshot interval is a period in milliseconds/seconds (broker-side policy) and must be non-negative; the CLI rejects negative values before contacting the broker.","triggerScenarios":"Running `pulsar-admin topics set-deduplication-snapshot-interval` with a negative --interval value, often from a computed variable or a typo like -100.","commonSituations":"Scripts computing the interval from configuration that yields -1 as a sentinel, sign typos, misunderstanding the unit and passing a negative 'disable' value instead of 0.","solutions":["Use 0 to disable snapshotting instead of a negative number","Pass a non-negative interval value","Check the script/config that computes the interval for sign errors"],"exampleFix":"// before\npulsar-admin topics set-deduplication-snapshot-interval --interval -1 -t my-topic\n// after\npulsar-admin topics set-deduplication-snapshot-interval --interval 0 -t my-topic","handlingStrategy":"validation","validationCode":"if (interval < 0) {\n    throw new IllegalArgumentException(\"Snapshot interval must be >= 0 (0 disables)\");\n}","typeGuard":"boolean isValidInterval(long interval) {\n    return interval >= 0;\n}","tryCatchPattern":"try {\n    admin.topicPolicies().setDeduplicationSnapshotInterval(topic, interval);\n} catch (ParameterException e) {\n    System.err.println(\"Interval must be non-negative\");\n}","preventionTips":["Clamp computed intervals with Math.max(0, value)","Use 0 to disable rather than negative sentinels","Validate config values before passing them to the CLI"],"tags":["pulsar-admin","cli","topic-policies","invalid-argument"],"backgroundTag":"invalid-parameter-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"}