dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'source8')
Error message
Value cannot be null. (Parameter 'source8')
What it means
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.
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.
Example fix
// before
var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, _selector); // _selector not initialized
// after
var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8,
(x1, x2, x3, x4, x5, x6, x7, x8) => (x1, x2, x3, x4, x5, x6, x7, x8)); Defensive patterns
Strategy: validation
Validate before calling
if (resultSelector == null)
throw new InvalidOperationException("resultSelector must be a non-null delegate");
var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, resultSelector); Type guard
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;
Try / catch
try
{
var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, selector);
}
catch (ArgumentNullException ex) when (ex.ParamName == "resultSelector")
{
logger.LogError(ex, "Zip selector was null");
selector = (a, b, c, d, e, f, g, h) => default;
return Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, selector);
} Prevention
- 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.
When it happens
Trigger: Calling Observable.Zip(source1..source8, resultSelector) with a null Func<TSource1..TSource8, TResult>; e.g. an unassigned delegate field or a resolver returning null.
Common situations: 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.
Related errors
- Value cannot be null. (Parameter 'source3')
- Value cannot be null. (Parameter 'source4')
- Value cannot be null. (Parameter 'source7')
- Value cannot be null. (Parameter 'sixth')
- nameof(subscribe)
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/40f8c598050a203a.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:333
if (source5 == null)
{
throw new ArgumentNullException(nameof(source5));
}
if (source6 == null)
{
throw new ArgumentNullException(nameof(source6));
}
if (source7 == null)
{
throw new ArgumentNullException(nameof(source7));
}
if (source8 == null)
{
throw new ArgumentNullException(nameof(source8));
}
if (resultSelector == null)
{
throw new ArgumentNullException(nameof(resultSelector));
}
return s_impl.Zip(source1, source2, source3, source4, source5, source6, source7, source8, resultSelector);
}
/// <summary>
/// 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.
/// </summary>
/// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
/// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
/// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
/// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
/// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>View on GitHub (pinned to 94b5d5ab91)