{"record":{"id":"4210577d0ff5ee62","repo":"dotnet/reactive","slug":"observer-skip","errorCode":null,"errorMessage":"observer","messagePattern":"observer","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Skip.cs","lineNumber":94,"sourceCode":"                source,\n                (duration, scheduler),\n                static async (source, state, observer) =>\n                {\n                    var (sourceObserver, timer) = await AsyncObserver.Skip(observer, state.duration).ConfigureAwait(false);\n\n                    var subscription = await source.SubscribeSafeAsync(sourceObserver).ConfigureAwait(false);\n\n                    return StableCompositeAsyncDisposable.Create(subscription, timer);\n                });\n        }\n    }\n\n    public partial class AsyncObserver\n    {\n        public static IAsyncObserver<TSource> Skip<TSource>(IAsyncObserver<TSource> observer, int count)\n        {\n            if (observer == null)\n                throw new ArgumentNullException(nameof(observer));\n            if (count <= 0)\n                throw new ArgumentOutOfRangeException(nameof(count));\n\n            return Create<TSource>(\n                async x =>\n                {\n                    if (count == 0)\n                    {\n                        await observer.OnNextAsync(x).ConfigureAwait(false);\n                    }\n                    else\n                    {\n                        --count;\n                    }\n                },\n                observer.OnErrorAsync,\n                observer.OnCompletedAsync\n            );","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Skip.cs#L76-L112","documentation":"AsyncObserver.Skip(observer, count) throws ArgumentNullException with paramName \"observer\" when the downstream observer is null. This factory builds the skip-filtering observer and requires a valid target.","triggerScenarios":"Calling AsyncObserver.Skip(null, count), typically when a downstream observer variable was never assigned or an operator pipeline passed a null observer.","commonSituations":"Custom operator implementations wiring observers incorrectly; refactoring where the observer creation step was removed; mocking frameworks returning null observers in tests.","solutions":["Ensure a valid IAsyncObserver<TSource> is passed","Fix the operator composition so the downstream observer is created before Skip","Check test setup/mocks that return null observers"],"exampleFix":"// before\nvar obs = AsyncObserver.Skip(downstream, 3); // downstream is null\n// after\nvar downstream = AsyncObserver.Create<int>(...);\nvar obs = AsyncObserver.Skip(downstream, 3);","handlingStrategy":"validation","validationCode":"if (observer == null) throw new InvalidOperationException(\"downstream observer required\");\nvar obs = AsyncObserver.Skip(observer, count);","typeGuard":"bool IsValidObserver<T>(IAsyncObserver<T> o) => o != null;","tryCatchPattern":"try { var obs = AsyncObserver.Skip(downstream, count); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"observer\") { /* wire downstream before calling */ }","preventionTips":["Create downstream observers before composing operator factories","Check test mocks return real observers, not null","Validate observer arguments in custom operator helpers"],"tags":["null-argument","rx","observer"],"backgroundTag":"null-argument","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"}