dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'thirteenth')

Error message

Value cannot be null. (Parameter 'thirteenth')

What it means

The high-arity Zip overload null-checks every observable source before delegating to the internal implementation (s_impl.Zip). A null thirteenth sequence triggers the guard at Observable.Multiple.Zip.cs:1807, throwing ArgumentNullException with Parameter 'thirteenth'. This is deliberate fail-fast validation in System.Reactive.

Solutions

  1. Pass a valid IObservable<T> as the thirteenth argument, or substitute Observable.Empty<TThirteenth>().
  2. Null-check/coalesce all sources before composing the Zip call.
  3. Repair the factory/config path that yields null for this feed.
  4. For variable source counts, switch to Observable.Zip(IEnumerable<IObservable<T>>, Func<IList<T>, TResult>).
  5. Wrap the composition in try/catch (ArgumentNullException) with a contextual message.

Example fix

// before
return Observable.Zip(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); // a13 == null
// after
a13 ??= Observable.Empty<T13>();
return Observable.Zip(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15);
Defensive patterns

Strategy: validation

Validate before calling

a13 ??= Observable.Empty<T13>();

Type guard

static IObservable<T> EnsureSource<T>(IObservable<T>? s) => s ?? Observable.Empty<T>();

Try / catch

try { return Observable.Zip(a1, ..., a15); }
catch (ArgumentNullException ex) when (ex.ParamName == "thirteenth") { return Observable.Empty<(T1,...,T15)>(); }

Prevention

When it happens

Trigger: Calling the public static Observable.Zip overload that combines up to fifteen IObservable<T> sources with null in the thirteenth argument position, right before the call returns s_impl.Zip(first, ..., fifteenth).

Common situations: A data feed whose producer failed at startup leaving the slot null; template-generated code with an unfilled argument; dynamic stream lists indexed positionally beyond their length.

Related errors


AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15). Data as JSON: /api/errors/f492340069cb9513. Report an issue: GitHub.

Appendix: source

Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:1807

                throw new ArgumentNullException(nameof(fourth));
            if (fifth == null)
                throw new ArgumentNullException(nameof(fifth));
            if (sixth == null)
                throw new ArgumentNullException(nameof(sixth));
            if (seventh == null)
                throw new ArgumentNullException(nameof(seventh));
            if (eighth == null)
                throw new ArgumentNullException(nameof(eighth));
            if (ninth == null)
                throw new ArgumentNullException(nameof(ninth));
            if (tenth == null)
                throw new ArgumentNullException(nameof(tenth));
            if (eleventh == null)
                throw new ArgumentNullException(nameof(eleventh));
            if (twelfth == null)
                throw new ArgumentNullException(nameof(twelfth));
            if (thirteenth == null)
                throw new ArgumentNullException(nameof(thirteenth));
            if (fourteenth == null)
                throw new ArgumentNullException(nameof(fourteenth));
            if (fifteenth == null)
                throw new ArgumentNullException(nameof(fifteenth));

            return s_impl.Zip(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth);
        }

        /// <summary>
        /// Merges the specified observable sequences into one observable sequence of tuple values whenever all of the observable sequences have produced an element at a corresponding index.
        /// </summary>
        /// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>
        /// <typeparam name="TSecond">The type of the elements in the second source sequence.</typeparam>
        /// <typeparam name="TThird">The type of the elements in the third source sequence.</typeparam>
        /// <typeparam name="TFourth">The type of the elements in the fourth source sequence.</typeparam>
        /// <typeparam name="TFifth">The type of the elements in the fifth source sequence.</typeparam>
        /// <typeparam name="TSixth">The type of the elements in the sixth source sequence.</typeparam>
        /// <typeparam name="TSeventh">The type of the elements in the seventh source sequence.</typeparam>

View on GitHub (pinned to 94b5d5ab91)