{"record":{"id":"5853b9dbe89b360d","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-source2","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source2')","messagePattern":"Value cannot be null\\. \\(Parameter 'source2'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Zip.Generated.cs","lineNumber":496,"sourceCode":"                var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();\n                var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();\n                var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();\n                var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();\n                var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();\n                var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();\n\n                await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7).ConfigureAwait(false);\n\n                return d;\n            });\n        }\n\n        public static IAsyncObservable<TResult> Zip<T1, T2, T3, T4, T5, T6, T7, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, Func<T1, T2, T3, T4, T5, T6, T7, TResult> selector)\n        {\n            if (source1 == null)\n                throw new ArgumentNullException(nameof(source1));\n            if (source2 == null)\n                throw new ArgumentNullException(nameof(source2));\n            if (source3 == null)\n                throw new ArgumentNullException(nameof(source3));\n            if (source4 == null)\n                throw new ArgumentNullException(nameof(source4));\n            if (source5 == null)\n                throw new ArgumentNullException(nameof(source5));\n            if (source6 == null)\n                throw new ArgumentNullException(nameof(source6));\n            if (source7 == null)\n                throw new ArgumentNullException(nameof(source7));\n            if (selector == null)\n                throw new ArgumentNullException(nameof(selector));\n\n            return Create<TResult>(async observer =>\n            {\n                var d = new CompositeAsyncDisposable();\n\n                var (observer1, observer2, observer3, observer4, observer5, observer6, observer7) = AsyncObserver.Zip(observer, selector);","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Zip.Generated.cs#L478-L514","documentation":"ArgumentNullException thrown by the generated 7-source Zip operator because source2 (the second IAsyncObservable) is null. The generated Zip overloads validate each source and the selector in order, so a null second source is reported with parameter name 'source2'.","triggerScenarios":"Calling source1.Zip(s2, s3, s4, s5, s6, s7, selector) where the second argument is null — e.g. an array/field element that was never populated. Note source1 must also be non-null (checked first).","commonSituations":"Building the list of streams from a collection with missing entries; a nullable observable property not yet initialized; misordered arguments in a long call.","solutions":["Pass a valid second observable; substitute AsyncObservable.Empty<T2>() if 'no elements' is intended","Check where source2 is produced/loaded (DI, array index, property init)","Verify argument order in the long Zip call — a shifted argument list is a common cause"],"exampleFix":"// before\nvar zipped = s1.Zip(streams[0], streams[1], streams[2], streams[3], streams[4], streams[5], sel); // streams[0] == null\n// after\nvar s2 = streams[0] ?? AsyncObservable.Empty<T2>();\nvar zipped = s1.Zip(s2, streams[1], streams[2], streams[3], streams[4], streams[5], sel);","handlingStrategy":"validation","validationCode":"if (source2 is null) throw new InvalidOperationException(\"Zip requires all source observables; source2 was null.\");\nvar sources = new[] { s1, s2, s3, s4, s5, s6, s7 };\nif (sources.Any(s => s is null)) throw new InvalidOperationException(\"All Zip sources must be non-null.\");","typeGuard":"bool AllNonNull<T>(params IAsyncObservable<T>?[] sources) => sources.All(s => s is not null);","tryCatchPattern":"try { var zipped = s1.Zip(s2, s3, s4, s5, s6, s7, selector); }\ncatch (ArgumentNullException ex) when (ex.ParamName is \"source1\" or \"source2\" or \"source3\" or \"source4\" or \"source5\" or \"source6\" or \"source7\")\n{\n    // substitute empty observables for missing sources or surface pipeline misconfiguration\n    throw new InvalidOperationException($\"Zip input missing: {ex.ParamName}\", ex);\n}","preventionTips":["Build long Zip calls from a validated list of sources, checking every element","Replace optional streams with AsyncObservable.Empty<T>() rather than null","Double-check argument order in generated/long operator signatures"],"tags":["argument-null","asyncrx","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"}