{"record":{"id":"5bef138350f61d36","repo":"dotnet/reactive","slug":"null-parameter-values","errorCode":null,"errorMessage":"null (Parameter 'values')","messagePattern":"null \\(Parameter 'values'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Append.cs","lineNumber":188,"sourceCode":"                                {\n                                    await observer.OnNextAsync(value).RendezVous(scheduler, ct);\n                                    await observer.OnCompletedAsync().RendezVous(scheduler, ct);\n                                }\n                            }).ConfigureAwait(false);\n\n                            await d.AssignAsync(task).ConfigureAwait(false);\n                        }\n                    ),\n                    d\n                );\n        }\n\n        public static IAsyncObserver<TSource> Append<TSource>(IAsyncObserver<TSource> observer, params TSource[] values)\n        {\n            if (observer == null)\n                throw new ArgumentNullException(nameof(observer));\n            if (values == null)\n                throw new ArgumentNullException(nameof(values));\n\n            return Create<TSource>(\n                observer.OnNextAsync,\n                observer.OnErrorAsync,\n                async () =>\n                {\n                    foreach (var value in values)\n                    {\n                        await observer.OnNextAsync(value).ConfigureAwait(false);\n                    }\n\n                    await observer.OnCompletedAsync().ConfigureAwait(false);\n                }\n            );\n        }\n\n        public static (IAsyncObserver<TSource>, IAsyncDisposable) Append<TSource>(IAsyncObserver<TSource> observer, IAsyncScheduler scheduler, params TSource[] values)\n        {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Append.cs#L170-L206","documentation":"The params-array Append overload (IAsyncObserver, params TSource[]) treats the values array as required: it is enumerated and forwarded to the observer after the source completes. A null array (which is what you get when you explicitly pass null for the params parameter) is rejected with ArgumentNullException in the short message form (\"null (Parameter 'values')\").","triggerScenarios":"Calling AsyncObservable.Append(observer, null) where null is bound to the params TSource[] values parameter (note: Append(observer) alone is legal because params allows zero values, but Append(observer, (int[])null) throws).","commonSituations":"Building the values list dynamically and passing a null array variable; calling Append through reflection/delegates that bypass params expansion and pass a null array; generic helper code forwarding an uninitialized array.","solutions":["Pass an actual array (possibly empty) — e.g. Append(observer, Array.Empty<TSource>()) or simply omit the argument to append nothing.","Coalesce at the call site: Append(observer, values ?? Array.Empty<TSource>()).","Fix the producer of the array so it returns an empty collection instead of null."],"exampleFix":"// before\nAsyncObservable.Append(observer, (int[])null);\n// after\nAsyncObservable.Append(observer, values ?? Array.Empty<int>());","handlingStrategy":"validation","validationCode":"if (values is null) values = Array.Empty<TSource>();\nvar appended = AsyncObservable.Append(observer, values);","typeGuard":"bool HasValues<T>(T[]? v) => v is not null; // note: empty array is valid, null is not","tryCatchPattern":"try { var appended = AsyncObservable.Append(observer, values); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"values\") { var appended = AsyncObservable.Append(observer, Array.Empty<TSource>()); }","preventionTips":["Prefer omitting the params argument (or Array.Empty) over passing a nullable array","Treat collections as never-null by convention; return empty collections from producers","When invoking via delegates/reflection, expand params instead of passing a raw array"],"tags":["argument-null","params-array","reactive","async"],"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"}