{"record":{"id":"7caf84dd1b16671c","repo":"apache/pulsar","slug":"sliding-interval-must-be-positive-slidinginterv-7caf84","errorCode":null,"errorMessage":"Sliding interval must be positive [${slidingIntervalDurationMs}]","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":61,"sourceCode":"        }\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            }\n            if (windowConfig.getWatermarkEmitIntervalMs() != null) {\n                if (windowConfig.getWatermarkEmitIntervalMs() <= 0) {\n                    throw new IllegalArgumentException(\n                            \"Watermark interval must be positive [\" + windowConfig.getWatermarkEmitIntervalMs() + \"]\");\n                }\n            }\n        }","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/WindowConfigUtils.java#L43-L79","documentation":"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.","triggerScenarios":"Calling WindowConfigUtils.validate(windowConfig) with a WindowConfig whose slidingIntervalDurationMs is non-null and <= 0 (e.g. 0L, -5000L).","commonSituations":"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.","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."],"exampleFix":"// before\nWindowConfig.builder().setSlidingIntervalDurationMs(-1000).setWindowLengthDurationMs(60000).build();\n// after\nWindowConfig.builder().setSlidingIntervalDurationMs(10000).setWindowLengthDurationMs(60000).build();","handlingStrategy":"validation","validationCode":"if (cfg.getSlidingIntervalDurationMs() != null && cfg.getSlidingIntervalDurationMs() <= 0) {\n    throw new IllegalArgumentException(\"slidingIntervalDurationMs must be > 0 ms, got \" + cfg.getSlidingIntervalDurationMs());\n}","typeGuard":null,"tryCatchPattern":"try {\n    WindowConfigUtils.validate(windowConfig);\n} catch (IllegalArgumentException e) {\n    log.error(\"Invalid window config: {}\", e.getMessage());\n    throw e;\n}","preventionTips":["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."],"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"}