{"record":{"id":"aabec4ae70bb8dbd","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-resultselector-aabec4","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'resultSelector')","messagePattern":"Value cannot be null\\. \\(Parameter 'resultSelector'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs","lineNumber":43,"sourceCode":"        {\n            if (source1 == null)\n            {\n                throw new ArgumentNullException(nameof(source1));\n            }\n\n            if (source2 == null)\n            {\n                throw new ArgumentNullException(nameof(source2));\n            }\n\n            if (source3 == null)\n            {\n                throw new ArgumentNullException(nameof(source3));\n            }\n\n            if (resultSelector == null)\n            {\n                throw new ArgumentNullException(nameof(resultSelector));\n            }\n\n            return s_impl.Zip(source1, source2, source3, resultSelector);\n        }\n\n        /// <summary>\n        /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.\n        /// </summary>\n        /// <typeparam name=\"TSource1\">The type of the elements in the first source sequence.</typeparam>\n        /// <typeparam name=\"TSource2\">The type of the elements in the second source sequence.</typeparam>\n        /// <typeparam name=\"TSource3\">The type of the elements in the third source sequence.</typeparam>\n        /// <typeparam name=\"TSource4\">The type of the elements in the fourth source sequence.</typeparam>\n        /// <typeparam name=\"TResult\">The type of the elements in the result sequence, returned by the selector function.</typeparam>\n        /// <param name=\"source1\">First observable source.</param>\n        /// <param name=\"source2\">Second observable source.</param>\n        /// <param name=\"source3\">Third observable source.</param>\n        /// <param name=\"source4\">Fourth observable source.</param>\n        /// <param name=\"resultSelector\">Function to invoke for each series of elements at corresponding indexes in the sources.</param>","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs#L25-L61","documentation":"Wait—this index refers to the four-source Zip overload's source1 check, but the error message says source1 at Observable.Multiple.Zip.cs:68. The four-source Observable.Zip overload throws ArgumentNullException when source1 is null. As with other Rx combinators, arguments are validated eagerly at the public boundary. Supply a non-null first IObservable.","triggerScenarios":"Calling Observable.Zip(source1, source2, source3, source4, resultSelector) with null as the first observable.","commonSituations":"The primary stream from a service/repository returning null on failure; conditional pipeline construction skipping the first source; refactor merging two sources into four without updating all arguments.","solutions":["Ensure the first observable is non-null before calling the four-source Zip.","Use Observable.Empty<TSource1>() as a fallback for an optional first source.","Run a null check across all sources and the selector before invoking Zip."],"exampleFix":"// before\nObservable.Zip(firstStream, s2, s3, s4, selector); // firstStream == null\n// after\nvar s1 = firstStream ?? Observable.Empty<FirstType>();\nObservable.Zip(s1, s2, s3, s4, selector);","handlingStrategy":"validation","validationCode":"if (source1 == null) source1 = Observable.Empty<TSource1>();","typeGuard":"bool IsValid<T>(IObservable<T> s) => s is not null;","tryCatchPattern":"try { return Observable.Zip(s1, s2, s3, s4, selector); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"source1\") { /* fall back to a default stream */ }","preventionTips":["Ensure service/repository methods return observable.Empty on failure rather than null","Validate every argument of multi-source zips before invocation","Use nullable-reference-type annotations on pipeline builder methods"],"tags":["null-argument","reactive-extensions","zip","argument-validation"],"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"}