{"record":{"id":"53798c5d547c3953","repo":"apache/pulsar","slug":"sliding-interval-must-be-positive-slidinginterv","errorCode":null,"errorMessage":"Sliding interval must be positive [${slidingIntervalCount}]","messagePattern":"Sliding interval must be positive \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/WindowConfigUtils.java","lineNumber":54,"sourceCode":"        }\n\n        if (windowConfig.getWindowLengthCount() != null) {\n            if (windowConfig.getWindowLengthCount() <= 0) {\n                throw new IllegalArgumentException(\n                        \"Window length must be positive [\" + windowConfig.getWindowLengthCount() + \"]\");\n            }\n        }\n\n        if (windowConfig.getWindowLengthDurationMs() != null) {\n            if (windowConfig.getWindowLengthDurationMs() <= 0) {\n                throw new IllegalArgumentException(\n                        \"Window length must be positive [\" + windowConfig.getWindowLengthDurationMs() + \"]\");\n            }\n        }\n\n        if (windowConfig.getSlidingIntervalCount() != null) {\n            if (windowConfig.getSlidingIntervalCount() <= 0) {\n                throw new IllegalArgumentException(\n                        \"Sliding interval must be positive [\" + windowConfig.getSlidingIntervalCount() + \"]\");\n            }\n        }\n\n        if (windowConfig.getSlidingIntervalDurationMs() != null) {\n            if (windowConfig.getSlidingIntervalDurationMs() <= 0) {\n                throw new IllegalArgumentException(\n                        \"Sliding interval must be positive [\" + windowConfig.getSlidingIntervalDurationMs() + \"]\");\n            }\n        }\n\n        if (windowConfig.getTimestampExtractorClassName() != null) {\n            if (windowConfig.getMaxLagMs() != null) {\n                if (windowConfig.getMaxLagMs() < 0) {\n                    throw new IllegalArgumentException(\n                            \"Lag duration must be positive [\" + windowConfig.getMaxLagMs() + \"]\");\n                }\n            }","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/WindowConfigUtils.java#L36-L72","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Set windowConfig.slidingIntervalCount to a positive integer (e.g. 100 messages).","If you intend time-based sliding, remove slidingIntervalCount (set to null) and set slidingIntervalDurationMs instead.","Run validate() on the WindowConfig locally before submitting the function to catch the bad value early."],"exampleFix":"// before\nWindowConfig.builder().setSlidingIntervalCount(0).setWindowLengthCount(1000).build();\n// after\nWindowConfig.builder().setSlidingIntervalCount(100).setWindowLengthCount(1000).build();","handlingStrategy":"validation","validationCode":"if (cfg.getSlidingIntervalCount() != null && cfg.getSlidingIntervalCount() <= 0) {\n    throw new IllegalArgumentException(\"slidingIntervalCount must be > 0, got \" + cfg.getSlidingIntervalCount());\n}","typeGuard":null,"tryCatchPattern":"try {\n    WindowConfigUtils.validate(windowConfig);\n} catch (IllegalArgumentException e) {\n    // surface a clear config error to the submitter / reject the update request\n}","preventionTips":["Never use 0 or -1 as 'unset' — use null so the field is treated as absent.","Call WindowConfigUtils.validate() in tests for every window config you ship.","Use builders with explicit positive constants rather than computed values without a lower-bound check."],"tags":["pulsar-functions","configuration","windowing","validation"],"backgroundTag":"config-validation-failed","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}