{"record":{"id":"583f3221bfde7107","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-source2-583f32","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source2')","messagePattern":"Value cannot be null\\. \\(Parameter 'source2'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs","lineNumber":33,"sourceCode":"        /// <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=\"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=\"resultSelector\">Function to invoke for each series of elements at corresponding indexes in the sources.</param>\n        /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source1\"/> or <paramref name=\"source2\"/> or <paramref name=\"source3\"/> or <paramref name=\"resultSelector\"/> is null.</exception>\n        public static IObservable<TResult> Zip<TSource1, TSource2, TSource3, TResult>(this IObservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, Func<TSource1, TSource2, TSource3, TResult> resultSelector)\n        {\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>","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs#L15-L51","documentation":"The Observable.Zip three-source overload throws ArgumentNullException when source2 is null. The public method checks source1, source2, source3, and resultSelector in order; this error means the second sequence failed the check. Supply a non-null IObservable as the second argument.","triggerScenarios":"Calling Observable.Zip(source1, source2, source3, resultSelector) with null as the second observable.","commonSituations":"A secondary stream (e.g. a settings or heartbeat observable) not yet created when zipping; event-stream registration returning null; merging UI and service streams where the service stream is unavailable.","solutions":["Ensure the second observable passed to Zip is non-null.","Substitute Observable.Empty<TSource2>() or Observable.Never<TSource2>() if the source is optional.","Validate each source for null before calling Zip."],"exampleFix":"// before\nfirst.Zip(secondStream, third, selector); // secondStream == null\n// after\nvar s2 = secondStream ?? Observable.Empty<SecondType>();\nfirst.Zip(s2, third, selector);","handlingStrategy":"validation","validationCode":"if (source2 == null) source2 = Observable.Empty<TSource2>();","typeGuard":"bool IsValid<T>(IObservable<T> s) => s is not null;","tryCatchPattern":"try { return Observable.Zip(source1, source2, source3, resultSelector); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"source2\") { /* replace with empty and retry */ }","preventionTips":["Default optional sources to Observable.Empty<T>() at construction","Assert secondary streams are initialized before pipeline composition","Keep stream creation and combination in one place to spot null wiring"],"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"}