apache/pulsar · error · ParameterException

Invalid interval '%d'.

Error message

Invalid interval '%d'. 

What it means

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.

Source

Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java:973

    }

    @Command(description = "Set deduplication snapshot interval for a topic")
    private class SetDeduplicationSnapshotInterval extends CliCommand {
        @Parameters(description = "persistent://tenant/namespace/topic", arity = "1")
        private String topicName;

        @Option(names = {"-i", "--interval"}, description =
                "Deduplication snapshot interval for topic in second, allowed range from 0 to Integer.MAX_VALUE",
                required = true)
        private int interval;

        @Option(names = {"--global", "-g"}, description = "Whether to set this policy globally.")
        private boolean isGlobal = false;

        @Override
        void run() throws PulsarAdminException {
            if (interval < 0) {
                throw new ParameterException(String.format("Invalid interval '%d'. ", interval));
            }

            String persistentTopic = validatePersistentTopic(topicName);
            getTopicPolicies(isGlobal).setDeduplicationSnapshotInterval(persistentTopic, interval);
        }
    }

    @Command(description = "Remove deduplication snapshot interval for a topic")
    private class RemoveDeduplicationSnapshotInterval extends CliCommand {

        @Parameters(description = "persistent://tenant/namespace/topic", arity = "1")
        private String topicName;

        @Option(names = {"--global", "-g"}, description = "Whether to remove this policy globally. ")
        private boolean isGlobal = false;

        @Override
        void run() throws PulsarAdminException {

View on GitHub (pinned to 820761864e)

Solutions

  1. Use 0 to disable snapshotting instead of a negative number
  2. Pass a non-negative interval value
  3. Check the script/config that computes the interval for sign errors

Example fix

// before
pulsar-admin topics set-deduplication-snapshot-interval --interval -1 -t my-topic
// after
pulsar-admin topics set-deduplication-snapshot-interval --interval 0 -t my-topic
Defensive patterns

Strategy: validation

Validate before calling

if (interval < 0) {
    throw new IllegalArgumentException("Snapshot interval must be >= 0 (0 disables)");
}

Type guard

boolean isValidInterval(long interval) {
    return interval >= 0;
}

Try / catch

try {
    admin.topicPolicies().setDeduplicationSnapshotInterval(topic, interval);
} catch (ParameterException e) {
    System.err.println("Interval must be non-negative");
}

Prevention

When it happens

Trigger: Running `pulsar-admin topics set-deduplication-snapshot-interval` with a negative --interval value, often from a computed variable or a typo like -100.

Common situations: 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.

Understand the failure class

Background: "must be positive", "Invalid value": how libraries reject invalid parameter values (ValueError, ArgumentError, INVALID_PARAMETER_VALUE) — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/94cf831cd0d38b0b. Report an issue: GitHub.