{"record":{"id":"72bf21fcc98a3025","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-source6-observable-multiple","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source6')","messagePattern":"Value cannot be null\\. \\(Parameter 'source6'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs","lineNumber":198,"sourceCode":"\n            if (source3 == null)\n            {\n                throw new ArgumentNullException(nameof(source3));\n            }\n\n            if (source4 == null)\n            {\n                throw new ArgumentNullException(nameof(source4));\n            }\n\n            if (source5 == null)\n            {\n                throw new ArgumentNullException(nameof(source5));\n            }\n\n            if (source6 == null)\n            {\n                throw new ArgumentNullException(nameof(source6));\n            }\n\n            if (resultSelector == null)\n            {\n                throw new ArgumentNullException(nameof(resultSelector));\n            }\n\n            return s_impl.CombineLatest(source1, source2, source3, source4, source5, source6, resultSelector);\n        }\n\n        /// <summary>\n        /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.\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=\"TSource5\">The type of the elements in the fifth source sequence.</typeparam>","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs#L180-L216","documentation":"Rx.NET's CombineLatest<T1..T6,TResult> overload (Observable.Multiple.CombineLatest.cs:198) eagerly validates every argument when the public extension method is invoked, before any subscription happens. A null sixth source observable makes it impossible to subscribe or combine values, so the library throws ArgumentNullException with the parameter name 'source6' synchronously at call time rather than surfacing an error through the observable pipeline. This fail-fast contract is documented via <exception cref=\"ArgumentNullException\"> on the method.","triggerScenarios":"Calling Observable.CombineLatest(source1..source5, source6, resultSelector) with the 6-source overload where source6 is null, e.g. a dictionary lookup, conditional, or optional field returned null for the sixth observable.","commonSituations":"Building observables from nullable configuration values where one entry is missing; passing results of a factory method that can return null; refactoring code that changed an array of sources into discrete parameters and one slot is unpopulated; tests wiring up 6 streams where one dependency failed to initialize.","solutions":["Ensure the sixth argument is a valid non-null IObservable<T> before calling CombineLatest (e.g. Observable.Empty<T>() or Observable.Never<T>() as a default).","Coalesce with the null-coalescing operator: source6 ?? Observable.Empty<T6>().","If the source may legitimately be absent, gate the CombineLatest call behind a null check or use a conditional expression to pick an alternative overload."],"exampleFix":"// before\nvar combined = Observable.CombineLatest(s1, s2, s3, s4, s5, sources[5], (a,b,c,d,e,f) => f);\n// after\nvar sixth = sources[5] ?? Observable.Empty<T6>();\nvar combined = Observable.CombineLatest(s1, s2, s3, s4, s5, sixth, (a,b,c,d,e,f) => f);","handlingStrategy":"validation","validationCode":"if (source6 is null) throw new InvalidOperationException(\"source6 must be provided before combining\");\n// or default it: var s6 = source6 ?? Observable.Empty<T6>();","typeGuard":"static bool IsSourceValid<T>(IObservable<T>? s) => s is not null;","tryCatchPattern":"try { var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, sel); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"source6\") { Log.Warning(\"source6 missing; using empty stream\"); combined = Observable.CombineLatest(s1, s2, s3, s4, s5, Observable.Empty<T6>(), sel); }","preventionTips":["Never pass nullable observable fields directly; coalesce with Observable.Empty or Observable.Never.","Validate all source streams at composition time with a helper that asserts non-null.","In tests, assert that every dependency observable is constructed before building queries.","Prefer Observable.Defer to delay composition until all streams are initialized."],"tags":["null-argument","argument-validation","reactive-extensions","combinelatest"],"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"}