dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'eighth')

Error message

Value cannot be null. (Parameter 'eighth')

What it means

ArgumentNullException with message "Value cannot be null. (Parameter 'eighth')" is thrown by the 10-source CombineLatest overload when the eighth source sequence is null. The operator validates all ten sources before constructing the Expression.Call for first.Provider.CreateQuery, because a null argument cannot appear in a valid queryable expression tree.

Solutions

  1. Pass a non-null IObservable<TEighth>; coalesce with Observable.Empty<TEighth>() when absence is legitimate.
  2. Fix the stream producer so it never returns null (return Empty or throw a meaningful error).
  3. Use a lower-arity CombineLatest overload to omit the eighth source.

Example fix

// before
var combined = first.CombineLatest(second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth);
// after
var combined = first.CombineLatest(second, third, fourth, fifth, sixth, seventh, eighth ?? Observable.Empty<TEighth>(), ninth, tenth);
Defensive patterns

Strategy: validation

Validate before calling

if (eighth is null) throw new InvalidOperationException("eighth source must be a non-null IObservable<TEighth>");
// or: eighth ??= Observable.Empty<TEighth>();

Type guard

static bool IsValidSource<T>(IObservable<T>? source) => source is not null;

Try / catch

try
{
    var combined = first.CombineLatest(second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth);
}
catch (ArgumentNullException ex) when (ex.ParamName == "eighth")
{
    // handle missing eighth source
}

Prevention

When it happens

Trigger: Calling QbservableEx.CombineLatest with eighth == null; the guard at QbservableEx.Homoicon.cs:421-422 executes after the first seven sources validate.

Common situations: Large multi-stream merges where one stream factory returned null; optional streams represented as null instead of Empty; DI or factory wiring that skipped one source.

Related errors


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

Appendix: source

Thrown at Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs:421

        /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="third" /> or <paramref name="fourth" /> or <paramref name="fifth" /> or <paramref name="sixth" /> or <paramref name="seventh" /> or <paramref name="eighth" /> or <paramref name="ninth" /> or <paramref name="tenth" /> is null.</exception>
        public static IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth)> CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TTenth>(this IQbservable<TFirst> first, IObservable<TSecond> second, IObservable<TThird> third, IObservable<TFourth> fourth, IObservable<TFifth> fifth, IObservable<TSixth> sixth, IObservable<TSeventh> seventh, IObservable<TEighth> eighth, IObservable<TNinth> ninth, IObservable<TTenth> tenth)
        {
            if (first == null)
                throw new ArgumentNullException(nameof(first));
            if (second == null)
                throw new ArgumentNullException(nameof(second));
            if (third == null)
                throw new ArgumentNullException(nameof(third));
            if (fourth == null)
                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));

            return first.Provider.CreateQuery<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth)>(
                Expression.Call(
                    null,
                    new Func<IQbservable<TFirst>, IObservable<TSecond>, IObservable<TThird>, IObservable<TFourth>, IObservable<TFifth>, IObservable<TSixth>, IObservable<TSeventh>, IObservable<TEighth>, IObservable<TNinth>, IObservable<TTenth>, IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth)>>(CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TTenth>).Method,
                    first.Expression,
                    GetSourceExpression(second),
                    GetSourceExpression(third),
                    GetSourceExpression(fourth),
                    GetSourceExpression(fifth),
                    GetSourceExpression(sixth),
                    GetSourceExpression(seventh),
                    GetSourceExpression(eighth),
                    GetSourceExpression(ninth),

View on GitHub (pinned to 94b5d5ab91)