dotnet/reactive · error · ArgumentNullException
source14
Error message
source14
What it means
System.ArgumentNullException thrown by the 14-source public Zip overload in Observable.Multiple.Zip.cs when the last source sequence (source14) is null. Zip validates each of its fourteen source parameters and finally its resultSelector; a null source14 fails that check and the operator never gets created. The eager throw prevents a null reference deeper inside the zipper when it tried to subscribe to the fourteenth sequence.
Solutions
- Ensure source14 is assigned to a valid observable before calling Zip.
- If the last stream is optional, pass Observable.Empty<T>() (note: Zip yields no items if any input is empty, so consider CombineLatest or skipping that source).
- Guard with ArgumentNullException.ThrowIfNull(s14) prior to the call for a clearer local failure.
- Consolidate sources into an array and use the collection Zip overload, asserting all elements are non-null beforehand.
Example fix
// before var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, selector); // s14 == null // after var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14 ?? Observable.Empty<bool>(), selector);
Defensive patterns
Strategy: validation
Validate before calling
if (s14 is null) throw new ArgumentNullException(nameof(s14));
Type guard
static bool IsValidSource<T>(IObservable<T>? s) => s is not null;
Try / catch
try { var zipped = Observable.Zip(s1, ..., s13, s14, selector); } catch (ArgumentNullException ex) when (ex.ParamName == "source14") { // use Observable.Empty<T>() or restructure with CombineLatest } Prevention
- Verify the last-added stream in a Zip chain is actually started before composition.
- Remember Zip emits nothing if any input is empty; design optional streams accordingly.
- Run nullable-reference-type analysis in CI to flag uninitialized observable fields.
- Prefer fewer, collection-based Zip calls over 14 positional arguments to reduce null-slot mistakes.
When it happens
Trigger: Calling Observable.Zip(s1, ..., s13, s14, resultSelector) with the fourteenth argument as a null IObservable reference (resultSelector itself non-null, since that check follows).
Common situations: A chain of streams extended one item too far where the last stream was never wired (e.g. a background producer that failed to start and left its Subject/observable field null); copy-paste of a Zip call from a 13-source snippet with one extra argument added; null returned by a service that resolves the final stream.
Related errors
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/2fcd4f3f073f058a.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:918
if (source11 == null)
{
throw new ArgumentNullException(nameof(source11));
}
if (source12 == null)
{
throw new ArgumentNullException(nameof(source12));
}
if (source13 == null)
{
throw new ArgumentNullException(nameof(source13));
}
if (source14 == null)
{
throw new ArgumentNullException(nameof(source14));
}
if (resultSelector == null)
{
throw new ArgumentNullException(nameof(resultSelector));
}
return s_impl.Zip(source1, source2, source3, source4, source5, source6, source7, source8, source9, source10, source11, source12, source13, source14, 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)