apache/pulsar · error · IllegalArgumentException

Window length is not specified

Error message

Window length is not specified

What it means

Thrown by WindowConfigUtils.validate when a WindowConfig specifies neither windowLengthDurationMs nor windowLengthCount. A window function needs exactly one way to delimit window length (time-based or count-based); with both null the windowing runtime cannot compute window boundaries, so the config is rejected at submission time.

Source

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

 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.pulsar.functions.utils;

import org.apache.pulsar.common.functions.WindowConfig;

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() + "]");

View on GitHub (pinned to 820761864e)

Solutions

  1. Set exactly one of windowLengthDurationMs (time-based) or windowLengthCount (count-based) on the WindowConfig.
  2. If configuring via CLI/JSON, provide --window-length-duration-ms or --window-length-count.
  3. Check the config file/keys for misspellings that leave both fields null after parsing.

Example fix

// before
WindowConfig config = new WindowConfig(); // neither length set
// after
WindowConfig config = new WindowConfig();
config.setWindowLengthDurationMs(10_000L); // or setWindowLengthCount(100)
Defensive patterns

Strategy: validation

Validate before calling

static void requireWindowLength(WindowConfig wc) {
    if (wc.getWindowLengthDurationMs() == null && wc.getWindowLengthCount() == null) {
        throw new IllegalArgumentException(
            "windowConfig must set exactly one of windowLengthDurationMs or windowLengthCount before validation");
    }
}

Try / catch

try {
    WindowConfigUtils.validate(windowConfig);
} catch (IllegalArgumentException e) {
    if ("Window length is not specified".equals(e.getMessage())) {
        windowConfig.setWindowLengthDurationMs(60_000L); // sane default, then retry
        WindowConfigUtils.validate(windowConfig);
        return;
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling WindowConfigUtils.validate(windowConfig) (directly or via function config validation when configuring a windowed function) where both getWindowLengthDurationMs() and getWindowLengthCount() return null — e.g. building WindowConfig programmatically without setting either field, or a YAML/JSON config omitting both keys.

Common situations: Programmatically constructed WindowConfig with defaults left unset; window config parsed from a properties file where keys were misspelled so neither field got populated; upgrading configs where the window-length key name changed; enabling windowing with only slidingInterval settings, forgetting the length.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


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