apache/pulsar · error · IllegalArgumentException
Window length must be positive [${windowLengthCount}]
Error message
Window length must be positive [${windowLengthCount}] What it means
Window-function config validation in WindowConfigUtils.validate: a count-based window length was supplied (windowLengthCount set alone) but its value is zero or negative, which cannot define a valid tumbling window; the windowLengthCount value is the faulty input.
Source
Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/WindowConfigUtils.java:40
public class WindowConfigUtils {
public static final long DEFAULT_MAX_LAG_MS = 0; // no lag
public static final long DEFAULT_WATERMARK_EVENT_INTERVAL_MS = 1000; // 1s
public static void validate(WindowConfig windowConfig) {
if (windowConfig.getWindowLengthDurationMs() == null && windowConfig.getWindowLengthCount() == null) {
throw new IllegalArgumentException("Window length is not specified");
}
if (windowConfig.getWindowLengthDurationMs() != null && windowConfig.getWindowLengthCount() != null) {
throw new IllegalArgumentException(
"Window length for time and count are set! Please set one or the other.");
}
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() + "]");
}
}
View on GitHub (pinned to 820761864e)
Solutions
- Set windowLengthCount to a positive integer
Example fix
// before config.setWindowLengthCount(0); // after config.setWindowLengthCount(100);
Defensive patterns
Strategy: validation
Validate before calling
static void requirePositiveWindowLengthCount(WindowConfig wc) {
if (wc.getWindowLengthCount() != null && wc.getWindowLengthCount() <= 0) {
throw new IllegalArgumentException("windowLengthCount must be >= 1, got " + wc.getWindowLengthCount());
}
} Type guard
static boolean isValidWindowLengthCount(Integer count) {
return count != null && count > 0;
} Try / catch
try {
WindowConfigUtils.validate(windowConfig);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Window length must be positive")) {
throw new IllegalStateException("Fix window length settings: count must be a positive integer", e);
}
throw e;
} Prevention
- Clamp computed counts with Math.max(1, count) before setting them.
- Reject zero/empty numeric strings when parsing window config from properties.
- Never leave 0 as a placeholder value in window configs.
When it happens
Trigger: Calling WindowConfigUtils.validate(windowConfig) where getWindowLengthCount() != null and getWindowLengthCount() <= 0 — e.g. setWindowLengthCount(0), a negative value from a computed expression, or a zero default from a template.
Common situations: Building the count from an unvalidated property (parseInt of empty/0 string); math that computes the count as floor of something that can be 0; placeholder values left in config intending to be replaced later.
Understand the failure class
Background: "Invalid configuration value" and "Unsupported/Unknown setting value" errors: why libraries reject your config strings, numbers, and types — this error's family across 30 libraries.
Related errors
- Window length is not specified
- Window length for time and count are set! Please set one or
- Window length must be positive [${windowLengthDurationMs}]
- Inconsistent types found between function input type and tim
- Not implemented
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/13213c94ae151c5a.
Report an issue: GitHub.