{"record":{"id":"7e2c165ba8a78a1e","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-source7-7e2c16","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source7')","messagePattern":"Value cannot be null\\. \\(Parameter 'source7'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs","lineNumber":260,"sourceCode":"\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 (source7 == null)\n            {\n                throw new ArgumentNullException(nameof(source7));\n            }\n\n            if (resultSelector == null)\n            {\n                throw new ArgumentNullException(nameof(resultSelector));\n            }\n\n            return s_impl.Zip(source1, source2, source3, source4, source5, source6, source7, 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=\"TSource5\">The type of the elements in the fifth source sequence.</typeparam>","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs#L242-L278","documentation":"This ArgumentNullException is thrown by the 8-source overload's sibling (the 7-source Zip) when the seventh observable source is null. Rx.NET's Zip eagerly validates every argument before subscribing, because a null IObservable would otherwise fail later inside the query pipeline with a less-diagnosable NullReferenceException. The parameter name is embedded in the message via nameof(source7).","triggerScenarios":"Calling Observable.Zip(source1..source7, resultSelector) (the 7-argument overload in Observable.Multiple.Zip.cs) with source7 == null; the check at line 260 runs after source1-source6 validation passes.","commonSituations":"Building source arrays or tuples programmatically where the last element was never initialized; passing a method that returns IObservable<T> and forgetting it can return null on a fallback path; refactoring from a lower-arity Zip overload and leaving the last source unwired; deserializing a set of streams where one stream is absent.","solutions":["Ensure the seventh argument passed to Zip is a non-null IObservable<T>; initialize it or use Observable.Empty<TSource7>() as a placeholder.","Check the expression producing source7 (factory method, dictionary lookup, conditional assignment) for paths that yield null.","If a variable number of sources is needed, validate all sources before calling Zip, or use the array-based Observable.Zip overload that accepts IObservable<T>[] and guards there.","Fail fast: add a null check with a meaningful error message at the call site before composing the query."],"exampleFix":"// before\nvar merged = Observable.Zip(s1, s2, s3, s4, s5, s6, streams.Count > 6 ? streams[6] : null, (a, b, c, d, e, f, g) => g);\n// after\nvar s7 = streams.Count > 6 ? streams[6] : Observable.Empty<TSource7>();\nvar merged = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, (a, b, c, d, e, f, g) => g);","handlingStrategy":"validation","validationCode":"if (source7 == null)\n    throw new InvalidOperationException(\"source7 must be provided before calling Zip\");\nvar zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, source7, selector);","typeGuard":"static bool IsValidSource<T>(IObservable<T> s) => s is not null;","tryCatchPattern":"try\n{\n    var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, selector);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"source7\")\n{\n    logger.LogError(ex, \"Zip called with null source7\");\n    return Observable.Empty<TResult>();\n}","preventionTips":["Never pass raw nullable observables into Zip; coalesce with Observable.Empty<T>().","Validate all sources in one guard clause before composing the query.","Prefer Observable.Concat/empty placeholders over null for 'optional' streams."],"tags":["dotnet","reactive-extensions","null-argument","zip"],"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"}