dotnet/reactive · error · ArgumentNullException
source1
Error message
source1
What it means
The 15-source Zip overload throws ArgumentNullException when the first source observable is null. The public Zip method validates every source sequence synchronously before building the pipeline, because Zip cannot subscribe to a null sequence.
Solutions
- Pass a non-null IObservable<TSource1>; use Observable.Empty<TSource1>() when there is genuinely no data
- Fix the upstream producer to return Observable.Empty (or Observable.Throw) instead of null
- Add a null check/coalescing at the call site: source1 ?? Observable.Empty<TSource1>()
Example fix
// before var zipped = Observable.Zip(GetSource1(), s2 /* ... */, selector); // GetSource1() returned null // after var src1 = GetSource1() ?? Observable.Empty<TSource1>(); var zipped = Observable.Zip(src1, s2 /* ... */, selector);
Defensive patterns
Strategy: validation
Validate before calling
if (source1 is null) throw new ArgumentNullException(nameof(source1));
Type guard
bool IsUsableSource<T>(IObservable<T>? s) => s is not null;
Try / catch
try
{
var zipped = Observable.Zip(source1, ..., source15, selector);
}
catch (ArgumentNullException ex) when (ex.ParamName == "source1")
{
// substitute Observable.Empty<TSource1>() and retry composition
} Prevention
- Return Observable.Empty<T>() instead of null from producers of observables
- Null-coalesce optional streams at composition time with ?? Observable.Empty<T>()
- Enable nullable reference types to surface nullable IObservable fields at compile time
When it happens
Trigger: Calling Observable.Zip(source1, source2, ..., source15, resultSelector) with source1 == null; commonly the result of a query, factory method, or conditional expression that produced null instead of an empty sequence.
Common situations: A repository or service method returning null instead of Observable.Empty; uninitialized fields of type IObservable<T>; conditional chains like cond ? obs : null.
Related errors
- resultSelector
- action
- action (Parameter 'action')
- action (Parameter 'action')
- action (Value cannot be null)
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/7fa669858c48f483.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:970
/// <param name="source5">Fifth observable source.</param>
/// <param name="source6">Sixth observable source.</param>
/// <param name="source7">Seventh observable source.</param>
/// <param name="source8">Eighth observable source.</param>
/// <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="source15">Fifteenth 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="source15"/> 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, TSource15, 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, IObservable<TSource15> source15, Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, 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)View on GitHub (pinned to 94b5d5ab91)