{"record":{"id":"43a5ddf8e17df372","repo":"dotnet/reactive","slug":"specified-argument-was-out-of-the-range-of-valid-values-43a5dd","errorCode":null,"errorMessage":"Specified argument was out of the range of valid values. (Parameter 'skip')","messagePattern":"Specified argument was out of the range of valid values\\. \\(Parameter 'skip'\\)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Window.cs","lineNumber":227,"sourceCode":"\n            return subscription;\n        }\n    }\n\n    public partial class AsyncObserver\n    {\n        public static (IAsyncObserver<TSource>, IAsyncDisposable) Window<TSource>(IAsyncObserver<IAsyncObservable<TSource>> observer, IAsyncDisposable subscription, int count) => Window(observer, subscription, count, count);\n\n        public static (IAsyncObserver<TSource>, IAsyncDisposable) Window<TSource>(IAsyncObserver<IAsyncObservable<TSource>> observer, IAsyncDisposable subscription, int count, int skip)\n        {\n            if (observer == null)\n                throw new ArgumentNullException(nameof(observer));\n            if (subscription == null)\n                throw new ArgumentNullException(nameof(subscription));\n            if (count <= 0)\n                throw new ArgumentOutOfRangeException(nameof(count));\n            if (skip <= 0)\n                throw new ArgumentOutOfRangeException(nameof(skip));\n\n            var refCount = new RefCountAsyncDisposable(subscription);\n\n            var queue = new Queue<IAsyncSubject<TSource>>();\n            var n = 0;\n\n            return\n                (\n                    Create<TSource>\n                    (\n                        async x =>\n                        {\n                            foreach (var window in queue)\n                            {\n                                await window.OnNextAsync(x).ConfigureAwait(false);\n                            }\n\n                            var i = n - count + 1;","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Window.cs#L209-L245","documentation":"This ArgumentOutOfRangeException is thrown by the count/skip-based Window helper when skip is zero or negative. skip controls how many source elements are dropped between window starts, so it must be a positive integer. The validation happens synchronously at call time.","triggerScenarios":"Calling Window(source, count, skip) or the internal Window(observer, subscription, count, skip) with skip <= 0, e.g. a stride value read from settings as 0, or passing an offset variable that defaulted to 0.","commonSituations":"Configuring sliding windows where the stride was left at its default 0; copying an overload call and omitting a valid skip; computing skip from a percentage that rounds to 0.","solutions":["Pass a positive skip (>= 1).","Clamp before calling: skip = Math.Max(1, skip).","Use the count-only Window overload if you don't need a stride.","Validate the configuration value feeding skip and reject non-positive values early."],"exampleFix":"// before\nvar stride = settings.Skip; // 0\nvar windows = source.Window(5, stride);\n// after\nvar stride = Math.Max(1, settings.Skip);\nvar windows = source.Window(5, stride);","handlingStrategy":"validation","validationCode":"if (skip < 1) throw new ArgumentOutOfRangeException(nameof(skip), skip, \"Window skip must be positive.\");\n// or clamp: skip = Math.Max(1, skip);","typeGuard":"bool IsValidSkip(int skip) => skip > 0;","tryCatchPattern":"try\n{\n    var windows = source.Window(count, skip);\n}\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"skip\")\n{\n    skip = 1; // tumbling windows\n}","preventionTips":["Default stride configuration to 1, not 0.","Validate both count and skip together since they come as a pair.","Document that skip is a stride and must be >= 1."],"tags":["argument-out-of-range","argument-validation","async-rx","window-operator"],"backgroundTag":"argument-out-of-range","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}