{"record":{"id":"40f8c598050a203a","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-source8-40f8c5","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source8')","messagePattern":"Value cannot be null\\. \\(Parameter 'source8'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs","lineNumber":333,"sourceCode":"\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 (source8 == null)\n            {\n                throw new ArgumentNullException(nameof(source8));\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, source8, 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":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs#L315-L351","documentation":"Thrown by the 8-source Zip overload when the resultSelector delegate is null (check at line 333, the last validation before delegating to s_impl.Zip). Zip cannot align and combine elements without the selector, so Rx.NET rejects the call immediately with ArgumentNullException.","triggerScenarios":"Calling Observable.Zip(source1..source8, resultSelector) with a null Func<TSource1..TSource8, TResult>; e.g. an unassigned delegate field or a resolver returning null.","commonSituations":"Selector injected via DI/options that was never configured; conditional selector selection defaulting to null; heavy refactors where the lambda argument was dropped from the argument list of the 9-parameter call.","solutions":["Supply a non-null Func<TSource1..TSource8, TResult> as the final argument.","Default dynamically resolved selectors to a concrete lambda (e.g. building a tuple) instead of null.","Add a null guard for the selector before composing the query.","Count the arguments: the 8-source overload requires all eight sources plus the selector."],"exampleFix":"// before\nvar zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, _selector); // _selector not initialized\n// after\nvar zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8,\n    (x1, x2, x3, x4, x5, x6, x7, x8) => (x1, x2, x3, x4, x5, x6, x7, x8));","handlingStrategy":"validation","validationCode":"if (resultSelector == null)\n    throw new InvalidOperationException(\"resultSelector must be a non-null delegate\");\nvar zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, resultSelector);","typeGuard":"static bool IsValidSelector<T1,T2,T3,T4,T5,T6,T7,T8,R>(Func<T1,T2,T3,T4,T5,T6,T7,T8,R> f) => f is not null;","tryCatchPattern":"try\n{\n    var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, selector);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"resultSelector\")\n{\n    logger.LogError(ex, \"Zip selector was null\");\n    selector = (a, b, c, d, e, f, g, h) => default;\n    return Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, selector);\n}","preventionTips":["Always pass the selector inline as a lambda to avoid null delegate fields.","If selectors are resolved from configuration, validate them at startup.","Count arguments carefully: the 8-source overload takes eight sources plus the selector."],"tags":["dotnet","reactive-extensions","null-argument","delegate","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"}