{"record":{"id":"b69f23de1a19223d","repo":"dotnet/reactive","slug":"null-parameter-observer","errorCode":null,"errorMessage":"null (Parameter 'observer')","messagePattern":"null \\(Parameter 'observer'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Append.cs","lineNumber":138,"sourceCode":"                    var (sink, disposable) = AsyncObserver.Append(observer, state.scheduler, state.values);\n\n                    await d.AddAsync(disposable).ConfigureAwait(false);\n\n                    var subscription = await source.SubscribeSafeAsync(sink).ConfigureAwait(false);\n\n                    await d.AddAsync(subscription).ConfigureAwait(false);\n\n                    return d;\n                });\n        }\n    }\n\n    public partial class AsyncObserver\n    {\n        public static IAsyncObserver<TSource> Append<TSource>(IAsyncObserver<TSource> observer, TSource value)\n        {\n            if (observer == null)\n                throw new ArgumentNullException(nameof(observer));\n\n            return Create<TSource>(\n                observer.OnNextAsync,\n                observer.OnErrorAsync,\n                async () =>\n                {\n                    await observer.OnNextAsync(value).ConfigureAwait(false);\n                    await observer.OnCompletedAsync().ConfigureAwait(false);\n                }\n            );\n        }\n\n        public static (IAsyncObserver<TSource>, IAsyncDisposable) Append<TSource>(IAsyncObserver<TSource> observer, TSource value, IAsyncScheduler scheduler)\n        {\n            if (observer == null)\n                throw new ArgumentNullException(nameof(observer));\n            if (scheduler == null)\n                throw new ArgumentNullException(nameof(scheduler));","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Append.cs#L120-L156","documentation":"AsyncObserver.Append creates an observer that, on completion of the source, emits one extra fixed value. It requires a non-null downstream observer, so a null observer throws ArgumentNullException (message shown as \"null (Parameter 'observer')\"). The guard runs before the internal Create call wires OnNextAsync/OnErrorAsync/onCompleted delegates.","triggerScenarios":"Calling AsyncObserver.Append<TSource>(null, value), typically in hand-built observer pipelines or tests that inject the observer later.","commonSituations":"Custom operator composition where the downstream observer is created lazily and is still null, or a factory method returning null that is passed straight into Append.","solutions":["Pass a constructed IAsyncObserver<TSource> as the first argument.","Build the downstream observer before composing Append.","Add a caller-side null assertion with a descriptive message before the call."],"exampleFix":"// before\nvar obs = AsyncObserver.Append(sinkOpt, 42);\n// after\nvar obs = AsyncObserver.Append(sinkOpt ?? throw new InvalidOperationException(\"sink missing\"), 42);","handlingStrategy":"validation","validationCode":"if (observer == null) throw new InvalidOperationException(\"observer required before AsyncObserver.Append\");\nvar obs = AsyncObserver.Append(observer, value);","typeGuard":"bool HasObserver<TSource>(IAsyncObserver<TSource>? o) => o is not null;","tryCatchPattern":"try { var obs = AsyncObserver.Append(observer, value); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"observer\") { /* construct observer first */ }","preventionTips":["Resolve the downstream observer before appending terminal values.","Use non-nullable observer parameters in custom pipeline helpers.","Add pipeline-construction tests that would catch a null observer."],"tags":["argument-null","observer","append","async-rx"],"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"}