{"record":{"id":"14f8b63fa959a23f","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-onerror-asyncqueryableex","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'onError')","messagePattern":"Value cannot be null\\. \\(Parameter 'onError'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs","lineNumber":1078,"sourceCode":"                throw new ArgumentNullException(nameof(onCompleted));\n\n            return source.Provider.CreateQuery<TSource>(Expression.Call(Do__TSource__4__1(typeof(TSource)), source.Expression, onNext, onError, onCompleted));\n        }\n\n        private static MethodInfo? s_Do__TSource__4__2;\n        \n        private static MethodInfo Do__TSource__4__2(Type TSource) =>\n            (s_Do__TSource__4__2 ??\n            (s_Do__TSource__4__2 = new Func<IAsyncQueryable<object>, Expression<Func<object, Task>>, Expression<Func<Exception, Task>>, Expression<Func<Task>>, IAsyncQueryable<object>>(Do<object>).GetMethodInfo()!.GetGenericMethodDefinition())).MakeGenericMethod(TSource);\n\n        public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task>> onNext, Expression<Func<Exception, Task>> onError, Expression<Func<Task>> onCompleted)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n            if (onNext == null)\n                throw new ArgumentNullException(nameof(onNext));\n            if (onError == null)\n                throw new ArgumentNullException(nameof(onError));\n            if (onCompleted == null)\n                throw new ArgumentNullException(nameof(onCompleted));\n\n            return source.Provider.CreateQuery<TSource>(Expression.Call(Do__TSource__4__2(typeof(TSource)), source.Expression, onNext, onError, onCompleted));\n        }\n\n        private static MethodInfo? s_Expand__TSource__2__0;\n        \n        private static MethodInfo Expand__TSource__2__0(Type TSource) =>\n            (s_Expand__TSource__2__0 ??\n            (s_Expand__TSource__2__0 = new Func<IAsyncQueryable<object>, Expression<Func<object, CancellationToken, ValueTask<IAsyncEnumerable<object>>>>, IAsyncQueryable<object>>(Expand<object>).GetMethodInfo()!.GetGenericMethodDefinition())).MakeGenericMethod(TSource);\n\n        public static IAsyncQueryable<TSource> Expand<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, CancellationToken, ValueTask<IAsyncEnumerable<TSource>>>> selector)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n            if (selector == null)\n                throw new ArgumentNullException(nameof(selector));","sourceCodeStart":1060,"sourceCodeEnd":1096,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs#L1060-L1096","documentation":"ArgumentNullException thrown by the three-handler Do<TSource> extension when the onError expression (Expression<Func<Exception, Task>>) is null. The error handler is part of the provider expression tree, so it must be non-null and is validated after onNext. The message names 'onError'.","triggerScenarios":"Calling Do(source, onNext, null, onCompleted) — typically when error handling was optional in the caller's design or a handler-resolution step returned null for onError.","commonSituations":"Query pipelines where error logging is disabled by configuration; abstracted handler registries missing an entry for the error slot; copy-pasted Do calls with one argument deleted.","solutions":["Pass a no-op error handler: _ => Task.CompletedTask","Use a Do overload that omits onError when error handling is not required","Make the handler registry fall back to a default error expression","Guard configuration-driven wiring so a missing handler never yields null"],"exampleFix":"// before\nquery.Do(OnNext, cfg.OnErrorHandler /* null when disabled */, OnDone);\n// after\nquery.Do(OnNext, cfg.OnErrorHandler ?? (_ => Task.CompletedTask), OnDone);","handlingStrategy":"validation","validationCode":"if (onError is null) onError = _ => Task.CompletedTask;","typeGuard":"static bool HasError(Expression<Func<Exception, Task>>? h) => h is not null;","tryCatchPattern":"try { q = source.Do(onNext, onError, onCompleted); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"onError\") { q = source.Do(onNext, _ => Task.CompletedTask, onCompleted); }","preventionTips":["Default error handlers at the configuration/wiring layer","Never represent 'error handling disabled' as a null expression","Use narrower Do overloads when error handling is not needed"],"tags":["csharp","null-argument","expression-tree","do-operator"],"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"}