{"record":{"id":"e3fed90728fb64d8","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-source4","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source4')","messagePattern":"Value cannot be null\\. \\(Parameter 'source4'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Zip.Generated.cs","lineNumber":500,"sourceCode":"                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);\n\n                var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();\n                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();","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Zip.Generated.cs#L482-L518","documentation":"The 7-source Zip operator overload (async Func selector form preceding the non-selector overload at line 533) validates all arguments up front. A null was passed as the 4th source observable, so the library eagerly throws ArgumentNullException('source4') before any subscription happens. This is fail-fast argument validation: zipping requires every input sequence to be non-null.","triggerScenarios":"Calling AsyncObservable.Zip(source1, source2, source3, null, source5, source6, source7) or the analogous 7-ary overload with a null fourth IAsyncObservable argument.","commonSituations":"A source observable variable that results from a conditional lookup or optional chain is null at call time; refactoring reduced a 7-way zip to fewer inputs but the null placeholder was left in position 4; a factory method returning the 4th stream returned null on some code path.","solutions":["Pass a real IAsyncObservable for source4; if the input is genuinely optional, substitute AsyncObservable.Empty<T4>() so the zip completes immediately.","Guard before the call: check each source for null (throw or default) so the failure is caught at the construction site with a clear message.","If the 4th source may be absent, collapse to a lower-arity Zip overload (e.g. the 3-source one) instead of passing null."],"exampleFix":"// before\nvar merged = AsyncObservable.Zip(s1, s2, s3, maybeFourth, s5, s6, s7);\n// after\nvar merged = AsyncObservable.Zip(s1, s2, s3, maybeFourth ?? AsyncObservable.Empty<T4>(), s5, s6, s7);","handlingStrategy":"validation","validationCode":"if (source4 == null) throw new InvalidOperationException(\"source4 must be provided before zipping\");","typeGuard":"bool IsValidZipInput<T>(IAsyncObservable<T> s) => s is not null;","tryCatchPattern":"try\n{\n    var zipped = AsyncObservable.Zip(s1, s2, s3, s4, s5, s6, s7);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"source4\")\n{\n    logger.LogError(ex, \"4th zip source was null\");\n}","preventionTips":["Use nullable reference types (IAsyncObservable<T>?) so nullability is visible at compile time","Substitute AsyncObservable.Empty<T>() for optional streams instead of null","Centralize multi-source composition in a helper that validates all inputs"],"tags":["argument-null","zip","async-rx"],"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"}