dotnet/reactive · error · ArgumentNullException

throw new ArgumentNullException(nameof(sixteenth))

Error message

throw new ArgumentNullException(nameof(sixteenth))

What it means

QbservableEx.CombineLatest's 16-source overload validates all sixteen source sequences before building the query expression tree. If the sixteenth IObservable<TSixteenth> argument is null, it throws ArgumentNullException named 'sixteenth'. The library throws eagerly at query-composition time so the failure surfaces where the query is built, not when it is subscribed on a remote provider.

Solutions

  1. Pass a non-null IQbservable/IObservable as the sixteenth argument; use Observable.Empty<TSixteenth>() or Observable.Never<TSixteenth>() when no source exists
  2. Check where the sixteenth source is produced (factory method, dictionary lookup) and fix the code returning null
  3. Combine fewer sources if 16 are not genuinely needed, avoiding placeholder nulls

Example fix

// before
CombineLatest(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, maybeSixteenth);
// after
var sixteenth = maybeSixteenth ?? Observable.Empty<TSixteenth>();
CombineLatest(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, sixteenth);
Defensive patterns

Strategy: validation

Validate before calling

if (sixteenth == null)
    throw new InvalidOperationException("sixteenth source must be provided; use Observable.Empty<TSixteenth>() instead");

Type guard

bool HasSource<T>(IObservable<T> s) => s is not null;

Try / catch

try
{
    var query = Qbservable.CombineLatest(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, sixteenth);
}
catch (ArgumentNullException ex) when (ex.ParamName == "sixteenth")
{
    logger.LogError(ex, "16th CombineLatest source was null");
}

Prevention

When it happens

Trigger: Calling Qbservable.CombineLatest(first..fifteenth, sixteenth) where the sixteenth argument is a null IObservable reference — e.g. a variable assigned from a failed lookup, an uninitialized field, or a method returning null instead of Observable.Empty.

Common situations: Dynamically assembling a large tuple of observables where one member of a collection came back null; refactoring code that reduced source count and left a trailing null; interop layers wrapping legacy streams that return null on missing data.

Related errors


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

Appendix: source

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

                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));
            if (sixteenth == null)
                throw new ArgumentNullException(nameof(sixteenth));

            return first.Provider.CreateQuery<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth, TEleventh Eleventh, TTwelfth Twelfth, TThirteenth Thirteenth, TFourteenth Fourteenth, TFifteenth Fifteenth, TSixteenth Sixteenth)>(
                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>, IObservable<TEleventh>, IObservable<TTwelfth>, IObservable<TThirteenth>, IObservable<TFourteenth>, IObservable<TFifteenth>, IObservable<TSixteenth>, IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth, TEleventh Eleventh, TTwelfth Twelfth, TThirteenth Thirteenth, TFourteenth Fourteenth, TFifteenth Fifteenth, TSixteenth Sixteenth)>>(CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TTenth, TEleventh, TTwelfth, TThirteenth, TFourteenth, TFifteenth, TSixteenth>).Method,
                    first.Expression,
                    GetSourceExpression(second),
                    GetSourceExpression(third),
                    GetSourceExpression(fourth),
                    GetSourceExpression(fifth),
                    GetSourceExpression(sixth),
                    GetSourceExpression(seventh),
                    GetSourceExpression(eighth),
                    GetSourceExpression(ninth),
                    GetSourceExpression(tenth),
                    GetSourceExpression(eleventh),
                    GetSourceExpression(twelfth),
                    GetSourceExpression(thirteenth),

View on GitHub (pinned to 94b5d5ab91)