{"record":{"id":"6d03963b0d0470d0","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-values","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'values')","messagePattern":"Value cannot be null\\. \\(Parameter 'values'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Append.cs","lineNumber":267,"sourceCode":"                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, IEnumerable<TSource> values)\n        {\n            if (observer == null)\n                throw new ArgumentNullException(nameof(observer));\n            if (values == null)\n                throw new ArgumentNullException(nameof(values));\n            if (scheduler == null)\n                throw new ArgumentNullException(nameof(scheduler));\n\n            var d = new SingleAssignmentAsyncDisposable();\n\n            return\n                (\n                    Create<TSource>(\n                        observer.OnNextAsync,\n                        observer.OnErrorAsync,\n                        async () =>\n                        {\n                            var task = await scheduler.ScheduleAsync(async ct =>\n                            {\n                                var e = default(IEnumerator<TSource>);\n\n                                try\n                                {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Append.cs#L249-L285","documentation":"In Append(observer, IAsyncScheduler, IEnumerable<TSource>), the values sequence is enumerated and each element is scheduled to the observer after the source completes; a null sequence cannot be enumerated so the factory throws ArgumentNullException (long .NET form: \"Value cannot be null. (Parameter 'values')\"). Observer and values are validated before the scheduler, so this fires when observer and values state allow the values check to run with a null sequence.","triggerScenarios":"AsyncObservable.Append(observer, scheduler, null) where the third argument (IEnumerable<TSource> values) is null — typically a null list, array, or LINQ result.","commonSituations":"Config-driven value list that failed to load; dictionary/TryGetValue result null; a service method returning null instead of an empty collection; test fixtures with an unset sequence field.","solutions":["Pass a non-null IEnumerable (Enumerable.Empty<TSource>() when nothing to append).","Coalesce: Append(observer, scheduler, values ?? Enumerable.Empty<TSource>()).","Fix the producer so it returns empty collections, never null."],"exampleFix":"// before\nAsyncObservable.Append(observer, scheduler, (IEnumerable<int>)null);\n// after\nAsyncObservable.Append(observer, scheduler, values ?? Enumerable.Empty<int>());","handlingStrategy":"validation","validationCode":"if (values is null) values = Enumerable.Empty<TSource>();\nvar (obs, disp) = AsyncObservable.Append(observer, scheduler, values);","typeGuard":"bool HasValues<T>(IEnumerable<T>? v) => v is not null;","tryCatchPattern":"try { var (obs, disp) = AsyncObservable.Append(observer, scheduler, values); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"values\") { var (obs, disp) = AsyncObservable.Append(observer, scheduler, Enumerable.Empty<TSource>()); }","preventionTips":["Coalesce nullable sequences with Enumerable.Empty<T>() before Append","Enforce never-null collection conventions in services and config loaders","Fail fast at startup if configured append values failed to load"],"tags":["argument-null","ienumerable","scheduler","reactive"],"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"}