dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'fourteenth')

Error message

Value cannot be null. (Parameter 'fourteenth')

What it means

The 14-source QbservableEx.Zip overload checks all sequence arguments and throws ArgumentNullException with parameter name 'fourteenth' when the last source is null. This eager validation happens before Provider.CreateQuery builds the expression tree, so the query is never constructed.

Solutions

  1. Trace the expression supplying the fourteenth argument and eliminate the null source.
  2. Substitute Observable.Empty<TFourteenth>() when an absent stream should simply end the zip immediately.
  3. Validate all arguments before the call and branch to an alternative composition if any are null.

Example fix

// before
var fourteenth = config.LastStream; // may be null
var zipped = first.Zip(..., fourteenth);
// after
var fourteenth = config.LastStream ?? Observable.Empty<TFourteenth>();
var zipped = first.Zip(..., fourteenth);
Defensive patterns

Strategy: validation

Validate before calling

if (fourteenth == null) throw new InvalidOperationException("fourteenth source must be set before Zip");
var zipped = first.Zip(second, ..., thirteenth, fourteenth);

Type guard

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

Try / catch

try
{
    return first.Zip(..., fourteenth);
}
catch (ArgumentNullException ex) when (ex.ParamName == "fourteenth")
{
    logger.LogWarning("fourteenth source was null");
    return first.Zip(..., thirteenth, Observable.Empty<TFourteenth>());
}

Prevention

When it happens

Trigger: Calling the 14-argument Zip overload with a null 14th (fourteenth) IQbservable<TFourteenth> argument — typically the result of a method returning null or an unassigned last parameter.

Common situations: Long argument lists make it easy to pass the wrong (null) variable in the final position; dynamic assembly of streams where the last source failed to resolve; calling Zip from generated or templated code with a missing sequence.

Related errors


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

Appendix: source

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

                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));

            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)>(
                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>, 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)>>(Zip<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TTenth, TEleventh, TTwelfth, TThirteenth, TFourteenth>).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)