apache/pulsar · error · IllegalArgumentException

Sliding interval must be positive [${slidingIntervalCount}]

Error message

Sliding interval must be positive [${slidingIntervalCount}]

What it means

WindowConfigUtils.validate() checks that a function's WindowConfig is internally consistent before the function is registered or updated. This IllegalArgumentException is thrown when slidingIntervalCount (the number of messages per sliding window step) is provided but is zero or negative, which would make the windowing computation impossible to schedule. It is an upfront config sanity check so bad configs fail fast at submission rather than at runtime.

Source

Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/WindowConfigUtils.java:54

        }

        if (windowConfig.getWindowLengthCount() != null) {
            if (windowConfig.getWindowLengthCount() <= 0) {
                throw new IllegalArgumentException(
                        "Window length must be positive [" + windowConfig.getWindowLengthCount() + "]");
            }
        }

        if (windowConfig.getWindowLengthDurationMs() != null) {
            if (windowConfig.getWindowLengthDurationMs() <= 0) {
                throw new IllegalArgumentException(
                        "Window length must be positive [" + windowConfig.getWindowLengthDurationMs() + "]");
            }
        }

        if (windowConfig.getSlidingIntervalCount() != null) {
            if (windowConfig.getSlidingIntervalCount() <= 0) {
                throw new IllegalArgumentException(
                        "Sliding interval must be positive [" + windowConfig.getSlidingIntervalCount() + "]");
            }
        }

        if (windowConfig.getSlidingIntervalDurationMs() != null) {
            if (windowConfig.getSlidingIntervalDurationMs() <= 0) {
                throw new IllegalArgumentException(
                        "Sliding interval must be positive [" + windowConfig.getSlidingIntervalDurationMs() + "]");
            }
        }

        if (windowConfig.getTimestampExtractorClassName() != null) {
            if (windowConfig.getMaxLagMs() != null) {
                if (windowConfig.getMaxLagMs() < 0) {
                    throw new IllegalArgumentException(
                            "Lag duration must be positive [" + windowConfig.getMaxLagMs() + "]");
                }
            }

View on GitHub (pinned to 820761864e)

Solutions

  1. Set windowConfig.slidingIntervalCount to a positive integer (e.g. 100 messages).
  2. If you intend time-based sliding, remove slidingIntervalCount (set to null) and set slidingIntervalDurationMs instead.
  3. Run validate() on the WindowConfig locally before submitting the function to catch the bad value early.

Example fix

// before
WindowConfig.builder().setSlidingIntervalCount(0).setWindowLengthCount(1000).build();
// after
WindowConfig.builder().setSlidingIntervalCount(100).setWindowLengthCount(1000).build();
Defensive patterns

Strategy: validation

Validate before calling

if (cfg.getSlidingIntervalCount() != null && cfg.getSlidingIntervalCount() <= 0) {
    throw new IllegalArgumentException("slidingIntervalCount must be > 0, got " + cfg.getSlidingIntervalCount());
}

Try / catch

try {
    WindowConfigUtils.validate(windowConfig);
} catch (IllegalArgumentException e) {
    // surface a clear config error to the submitter / reject the update request
}

Prevention

When it happens

Trigger: Calling WindowConfigUtils.validate(windowConfig) (directly or via function registration/update APIs) with a WindowConfig whose slidingIntervalCount is non-null and <= 0 (e.g. 0, -1).

Common situations: Hand-writing window function configs in YAML/JSON and leaving a template value of 0; computing the count programmatically from another metric that evaluated to 0; copy-pasting a config and editing the wrong field; deserializing a config where the field defaulted to 0 instead of null.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


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