{"record":{"id":"145099e9af0ac849","repo":"dotnet/reactive","slug":"null-parameter-scheduler","errorCode":null,"errorMessage":"null (Parameter 'scheduler')","messagePattern":"null \\(Parameter 'scheduler'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Append.cs","lineNumber":156,"sourceCode":"                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));\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                                if (!ct.IsCancellationRequested)\n                                {\n                                    await observer.OnNextAsync(value).RendezVous(scheduler, ct);\n                                    await observer.OnCompletedAsync().RendezVous(scheduler, ct);\n                                }\n                            }).ConfigureAwait(false);","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Append.cs#L138-L174","documentation":"The Append operator's disposer-returning overload (IAsyncObserver, value, IAsyncScheduler) requires a non-null scheduler because appended values are emitted on that scheduler. System.Reactive.Async guards its public API surface eagerly, throwing ArgumentNullException with C# 10's raw parameter-name message format (\"null (Parameter 'scheduler')\") at the operator factory rather than failing later inside the async pipeline. Passing null means the operator could never schedule the appended value, so it fails fast.","triggerScenarios":"Calling AsyncObservable.Append(observer, value, scheduler) with scheduler == null, e.g. Append(observer, value, null) or a variable assigned from a lookup that returned null.","commonSituations":"Resolving the scheduler from a DI container or config that was not registered; caching a scheduler in a field whose initialization was skipped; migrating code that previously used a synchronous overload and passing null where a scheduler is now required.","solutions":["Pass a concrete IAsyncScheduler such as AsyncScheduler.Default (or AsyncScheduler.Immediate / a task-pool scheduler) at the call site.","If the scheduler comes from a caller or DI container, register/initialize it before constructing the Append operator.","Add a null check with a default at the call boundary: scheduler ??= AsyncScheduler.Default."],"exampleFix":"// before\nvar (obs, disp) = AsyncObservable.Append(observer, 42, null);\n// after\nvar (obs, disp) = AsyncObservable.Append(observer, 42, AsyncScheduler.Default);","handlingStrategy":"validation","validationCode":"if (scheduler is null) throw new InvalidOperationException(\"Append requires a scheduler; pass AsyncScheduler.Default.\");\nvar (obs, disp) = AsyncObservable.Append(observer, value, scheduler);","typeGuard":"bool HasScheduler(IAsyncScheduler? s) => s is not null;","tryCatchPattern":"try { var (obs, disp) = AsyncObservable.Append(observer, value, scheduler); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"scheduler\") { scheduler = AsyncScheduler.Default; /* retry */ }","preventionTips":["Default optional schedulers with `scheduler ??= AsyncScheduler.Default` at API boundaries","Verify DI registrations for any injected IAsyncScheduler","Never pass null where an overload exists without the scheduler parameter"],"tags":["argument-null","scheduler","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"}