dotnet/reactive · error · ArgumentNullException
source2
Error message
source2
What it means
In the 14-source Zip overload, the second sequence (source2) is validated to be non-null at line 858, right after source1. Zipping cannot proceed if any of the 14 input streams is null, so Rx throws ArgumentNullException with parameter name 'source2' at call time.
Solutions
- Replace the null in the second argument position with Observable.Empty<TSource2>().
- Fix the upstream producer that returned null for source2.
- Add explicit null checks for each source before calling Zip.
- Re-verify the argument ordering of all 14 sources in the call.
Example fix
// before var zipped = Observable.Zip(s1, null, s3, ..., s14, selector); // after var zipped = Observable.Zip(s1, s2 ?? Observable.Empty<TSource2>(), s3, ..., s14, selector);
Defensive patterns
Strategy: validation
Validate before calling
if (source2 == null) throw new ArgumentNullException(nameof(source2));
Type guard
static IObservable<T> NonNull<T>(IObservable<T> s) => s ?? Observable.Empty<T>();
Try / catch
try { var zipped = Observable.Zip(source1, source2, ...); } catch (ArgumentNullException ex) when (ex.ParamName == "source2") { /* substitute default source or abort */ } Prevention
- Validate each argument in order before calling multi-source Zip.
- Prefer Observable.Empty<T>() over null for optional streams.
- Keep long Zip call sites behind a checked helper to catch nulls once.
When it happens
Trigger: Calling the 14-argument Observable.Zip with null in the second position while source1 and the rest are valid observables.
Common situations: A null returned from a service/stream factory for the second feed, a misordered argument list in the long 15-parameter call, or an optional stream passed as null instead of Observable.Empty.
Related errors
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/93487b9460a8ae36.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:858
/// <param name="source9">Ninth observable source.</param>
/// <param name="source10">Tenth observable source.</param>
/// <param name="source11">Eleventh observable source.</param>
/// <param name="source12">Twelfth observable source.</param>
/// <param name="source13">Thirteenth observable source.</param>
/// <param name="source14">Fourteenth observable source.</param>
/// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
/// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source1"/> or <paramref name="source2"/> or <paramref name="source3"/> or <paramref name="source4"/> or <paramref name="source5"/> or <paramref name="source6"/> or <paramref name="source7"/> or <paramref name="source8"/> or <paramref name="source9"/> or <paramref name="source10"/> or <paramref name="source11"/> or <paramref name="source12"/> or <paramref name="source13"/> or <paramref name="source14"/> or <paramref name="resultSelector"/> is null.</exception>
public static IObservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>(this IObservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult> resultSelector)
{
if (source1 == null)
{
throw new ArgumentNullException(nameof(source1));
}
if (source2 == null)
{
throw new ArgumentNullException(nameof(source2));
}
if (source3 == null)
{
throw new ArgumentNullException(nameof(source3));
}
if (source4 == null)
{
throw new ArgumentNullException(nameof(source4));
}
if (source5 == null)
{
throw new ArgumentNullException(nameof(source5));
}
if (source6 == null)View on GitHub (pinned to 94b5d5ab91)