apache/pulsar · error · IllegalArgumentException
Sliding interval must be positive [${slidingIntervalDuration
Error message
Sliding interval must be positive [${slidingIntervalDurationMs}] What it means
WindowConfigUtils.validate() verifies windowing parameters of a WindowConfig before a function is registered. This IllegalArgumentException is thrown when slidingIntervalDurationMs is provided but is zero or negative — the sliding interval (how often the window advances in time) must be a positive duration for the windowing engine to schedule window evaluations. The check fails fast at submission time.
Source
Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/WindowConfigUtils.java:61
}
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() + "]");
}
}
if (windowConfig.getWatermarkEmitIntervalMs() != null) {
if (windowConfig.getWatermarkEmitIntervalMs() <= 0) {
throw new IllegalArgumentException(
"Watermark interval must be positive [" + windowConfig.getWatermarkEmitIntervalMs() + "]");
}
}
}View on GitHub (pinned to 820761864e)
Solutions
- Set windowConfig.slidingIntervalDurationMs to a positive value in milliseconds (e.g. 10000 for 10s).
- If you meant count-based sliding, set slidingIntervalDurationMs to null and provide a positive slidingIntervalCount.
- Fix unit conversions so the ms value is >= 1 before building the WindowConfig.
Example fix
// before WindowConfig.builder().setSlidingIntervalDurationMs(-1000).setWindowLengthDurationMs(60000).build(); // after WindowConfig.builder().setSlidingIntervalDurationMs(10000).setWindowLengthDurationMs(60000).build();
Defensive patterns
Strategy: validation
Validate before calling
if (cfg.getSlidingIntervalDurationMs() != null && cfg.getSlidingIntervalDurationMs() <= 0) {
throw new IllegalArgumentException("slidingIntervalDurationMs must be > 0 ms, got " + cfg.getSlidingIntervalDurationMs());
} Try / catch
try {
WindowConfigUtils.validate(windowConfig);
} catch (IllegalArgumentException e) {
log.error("Invalid window config: {}", e.getMessage());
throw e;
} Prevention
- Keep all durations in milliseconds consistently; verify unit conversions (seconds * 1000).
- Leave optional window fields null instead of 0.
- Validate configs at submission time (CI or CLI pre-check) rather than at worker runtime.
When it happens
Trigger: Calling WindowConfigUtils.validate(windowConfig) with a WindowConfig whose slidingIntervalDurationMs is non-null and <= 0 (e.g. 0L, -5000L).
Common situations: Specifying durations in the wrong unit (e.g. seconds value used where ms expected resulting in 0 after truncation); templated configs with 0 placeholders; programmatically computing the interval from a negative offset; typos like setting it to -1 to mean 'unset' 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
- Sliding interval must be positive [${slidingIntervalCount}]
- Function config is not provided
- Windows Function not support delivery semantics.
- Output topic %s is also being used as an input topic (topics
- Input topic %s is invalid
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/7caf84dd1b16671c.
Report an issue: GitHub.