{"record":{"id":"ce8ad0ecb24e7002","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-observer-all","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'observer')","messagePattern":"Value cannot be null\\. \\(Parameter 'observer'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/All.cs","lineNumber":43,"sourceCode":"        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n            if (predicate == null)\n                throw new ArgumentNullException(nameof(predicate));\n\n            return CreateAsyncObservable<bool>.From(\n                source,\n                predicate,\n                static (source, predicate, observer) => source.SubscribeSafeAsync(AsyncObserver.All(observer, predicate)));\n        }\n    }\n\n    public partial class AsyncObserver\n    {\n        public static IAsyncObserver<TSource> All<TSource>(IAsyncObserver<bool> observer, Func<TSource, bool> predicate)\n        {\n            if (observer == null)\n                throw new ArgumentNullException(nameof(observer));\n            if (predicate == null)\n                throw new ArgumentNullException(nameof(predicate));\n\n            return Create<TSource>(\n                async x =>\n                {\n                    var b = default(bool);\n\n                    try\n                    {\n                        b = predicate(x);\n                    }\n                    catch (Exception ex)\n                    {\n                        await observer.OnErrorAsync(ex).ConfigureAwait(false);\n                        return;\n                    }\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/All.cs#L25-L61","documentation":"The AsyncObserver.All factory (sync-predicate overload) creates the observer that implements the All operator and first validates its arguments. A null downstream observer means there is nowhere to deliver the resulting bool or error, so ArgumentNullException('observer') is thrown. This is an internal pipeline API; it is normally only hit when composing observers manually.","triggerScenarios":"Calling AsyncObserver.All<TSource>(null, predicate) directly, or wiring a custom subscription pipeline where the downstream IAsyncObserver<bool> was not yet constructed.","commonSituations":"Hand-rolling operator composition or tests that build AsyncObserver chains, where the observer argument is produced by another factory that returned null.","solutions":["Pass a non-null IAsyncObserver<bool>, typically obtained from CreateAsyncObserver or your sink implementation.","Construct the observer before building the All observer; never pass the result of an uninitialized factory call.","If you own wrapper code, assert the observer is non-null before forwarding to AsyncObserver.All."],"exampleFix":"// before\nIAsyncObserver<bool> sink = GetObserver(); // may return null\nvar obs = AsyncObserver.All(source, sink, pred);\n// after\nIAsyncObserver<bool> sink = GetObserver() ?? throw new InvalidOperationException(\"no sink\");\nvar obs = AsyncObserver.All(source, sink, pred);","handlingStrategy":"validation","validationCode":"if (observer == null) throw new InvalidOperationException(\"downstream observer must be constructed before AsyncObserver.All\");\nvar obs = AsyncObserver.All(source, observer, predicate);","typeGuard":"bool HasObserver<TSource>(IAsyncObserver<TSource>? o) => o is not null;","tryCatchPattern":"try { var obs = AsyncObserver.All(source, observer, predicate); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"observer\") { /* build the observer first */ }","preventionTips":["Construct downstream observers before composing operator observers.","In tests, use the library's Create/observer helpers instead of hand-built nulls.","Mark observer parameters as non-nullable to get compiler warnings."],"tags":["argument-null","observer","async-rx","internal-api"],"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"}